{"id":625,"date":"2021-03-31T06:55:54","date_gmt":"2021-03-31T06:55:54","guid":{"rendered":"https:\/\/mklasen.com\/?p=625"},"modified":"2021-03-31T06:55:55","modified_gmt":"2021-03-31T06:55:55","slug":"permission-issues-with-docker-compose-heres-a-fix","status":"publish","type":"post","link":"https:\/\/mklasen.com\/permission-issues-with-docker-compose-heres-a-fix\/","title":{"rendered":"Permission issues with docker compose? Here’s a fix."},"content":{"rendered":"\n
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.<\/p>\n\n\n\n
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.<\/p>\n\n\n\n
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.<\/p>\n\n\n\n
Below you’ll see an example. The user parameter is the important part. If you have issues, execute the following to commands: <\/p>\n\n\n\n
docker exec -it container_name id -u<\/code><\/pre>\n\n\n\nand compare it with:<\/p>\n\n\n\n
docker exec -it container_name ls -la \/var\/www<\/code><\/pre>\n\n\n\nUse the output of the last command to set your user parameter in your docker-compose.yml file.<\/p>\n\n\n\n
wordpress:\n container_name: ${NAME}-wordpress\n user: \"www-data:www-data\"<\/strong>\n build:\n context: \/home\/mklasen\/server-management\/config\/wordpress\n dockerfile: wordpress.Dockerfile\n depends_on:\n - db\n expose:\n - \"9000\"\n volumes:\n - \/home\/mklasen\/server-management\/config\/php\/default.conf:\/usr\/local\/etc\/php\/conf.d\/php.ini\n - .\/:\/var\/www\n - \/home\/mklasen\/server-management\/tmp\/xdebug:\/tmp\/xdebug\n links:\n - db\n external_links:\n - catchall\n environment:\n PHP_AUTOCONF: \/usr\/bin\/autoconf<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"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 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\n
Permission issues with docker compose? Here's a fix. - Marinus Klasen<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\n\n\n\t\n\t\n\t\n