I’m fairly new to docker-compose but did manage to run all my local development on docker containers recently. I even setup a mini-PC that runs all these environments and allows met to quickly spin up new websites (literally seconds). Oh and did I mention that all of the websites are accessible from any device within the network? The mini-PC also runs a DNS server, and the router is setup to use this DNS server by default.
Honestly – I am so happy with this new setup. I hope to get an Intel NUC soon and redo the full setup while creating a video or blog, but that might take a while.
Anyway, that’s not why you’re here…
While setting up all of these containers I ran into some frustrating permission issues. If you’re using docker-compose, i’ve got the fix right here for you.
Add the user parameter
Below you’ll see an example. The user parameter is the important part. If you have issues, execute the following to commands:
docker exec -it container_name id -u
and compare it with:
docker exec -it container_name ls -la /var/www
Use the output of the last command to set your user parameter in your docker-compose.yml file.
wordpress:
container_name: ${NAME}-wordpress
user: "www-data:www-data"
build:
context: /home/mklasen/server-management/config/wordpress
dockerfile: wordpress.Dockerfile
depends_on:
- db
expose:
- "9000"
volumes:
- /home/mklasen/server-management/config/php/default.conf:/usr/local/etc/php/conf.d/php.ini
- ./:/var/www
- /home/mklasen/server-management/tmp/xdebug:/tmp/xdebug
links:
- db
external_links:
- catchall
environment:
PHP_AUTOCONF: /usr/bin/autoconf
Leave a Reply