August 12, 2017

Docker & File Permissions

Linux desktop users may run into file permissions issues when sharing volumes with containers. In this video, we'll see what the issue is and how to fix it.

We cover checking how the data volume, used with the MySQL container, is setting file permissions. Then we apply that lesson to our application files, so our Docker container can write to the files it needs to.

For this one, I recommend watching the video, as the notes here don't really explain what's happening - we just see the mechanics of what was done.

docker exec -it php_container bash

# See that PHP runs as user www-data
> ps aux | grep php

# Check id of user www-data
> id www-data # will be "33" in Ubuntu containers/servers
> exit

# Back in our host machine
# Chown application directory
# to user id 33 to match the www-data user id
# which PHP runs as inside the container
chown -R 33 application/

Looking for a deeper dive into Docker?

Sign up here to get a preview of the Shipping Docker course! Learn how to integrate Docker into your applications and develop a workflow to make using Docker a breeze!

All Topics