Replies: 9 comments
-
@kyletozer Are you on Windows, Mac, or Linux? Docker Desktop or Docker Toolbox? |
Beta Was this translation helpful? Give feedback.
-
@robodude666 I am using Docker Desktop on Ubuntu Desktop 18.04. |
Beta Was this translation helpful? Give feedback.
-
@kyletozer I haven't used Docker on native linux yet, but I believe since the daemon is running as root and the container is running as root internally (or some other user) you can't mount a non-root directory to the container. I believe you'd have to make Try rootless mode as an alternative which was introduced recently. |
Beta Was this translation helpful? Give feedback.
-
@kyletozer there is no Docker Desktop for Linux, I'm confused. |
Beta Was this translation helpful? Give feedback.
-
You might try adding |
Beta Was this translation helpful? Give feedback.
-
Sorry for the confusion @BretFisher, I didn't mean Docker Desktop for Linux, just installed it and running it through the command line on Ubuntu desktop. I've found a temporary workaround that works quite well by using a feature of VS Code to connect remotely to my container and edit files directly on the container, allowing me to bypass any permissions issues I am currently having between my host and my containers. But perhaps I am doing things backwards? The files I am having trouble with were actually created on the container. These are not files that were originally created on my machine and placed in the bind mount folder after running I have tried your first suggestion of adding |
Beta Was this translation helpful? Give feedback.
-
I don't know of a walk through. But things are simpler in "docker on linux" because it's just pure Linux, there's actually no magic there, you just need to understand how Linux uses users, groups (uid, gid) and tools like chown/chmod. Every file has a user and group owner, and those are just numbers (user id, group id). The container will start the app as a uid:gid but those id's may not exist on the host, which is fine, it's a simple number matching system. So if a file is created in container as the Dockerfile USER directive, lets say that has a uid:gud of 999:999
Each use case is different so it's hard to give a "run this command to fix it" because it's all just Linux permissions problems. Once you learn the ends and outs of how file permissions and uid:gid work in Linux, the rest should work itself out :) |
Beta Was this translation helpful? Give feedback.
-
Please advise what vscode feature or plugin allows you to do that? It would be very helpful! |
Beta Was this translation helpful? Give feedback.
-
@lonix1 I think their talking about VS Code Remote. It's multiple extensions depending on how you want to access your code, including "Remote - Containers" extension: https://code.visualstudio.com/docs/remote/remote-overview |
Beta Was this translation helpful? Give feedback.
-
Hi Bret,
First off, just wanted to thank you for the fantastic material in your Udemy Docker Mastery course! And second off, after starting to dabble with containers and setups, I've been running into an issue with permissions when using bind mounts in a compose setup.
Anything created inside of the container is created with the containers permissions rightfully so and I am unable to modify the file or files on the host until I change the permissions. I was just wondering if there is a way around always having to change permissions on my host when something is created in the container? The setup in question that I'm testing is an attempt at dockerizing WordPress for practice.
The idea was to create a development environment where I could keep my site files out of the container and easily be able to edit them on the host through volume bind mapping but this is the issue I keep running into, is there a better way of doing what I am trying to do?
Here are my configs:
docker-compose.yml
In the wordpress service, I am mapping the path to the wordpress installation in the container to the src folder in my project. Appreciate any help with this, Thanks again!
Beta Was this translation helpful? Give feedback.
All reactions