I am still learning all about Dockers so please bare with me on the question. I have been running containers via Ubuntu 22 that was installed during the setup of Ubuntu Server and seems this might be my issue.
When creating a docker container via docker run -p port:port -v path/to/host:/path/to/container I keep getting permission issues. I have went through all the steps of doing docker group adding my account etc but still get permission errors.
I have found information online change permissions to daemon services etc but what is the proper way and why doesn’t it work right out the box? I want this to be secure but not open it up the wrong way.
Please share which installation method you used. The official Docker distribution for Ubuntu is installed by following this instructions.
Also, please copy/paste the exact error message you get when running the container.
Everytime you use a host path on the left hand side of the volume mapping (
-v) a bind is used instead of a volume (It will not be listed by
docker volume ls). This literally binds a host folder into a target folder of the container. When a bind is used, you need to make sure the owner UID/GID of the host folder is alligned with the UID/GID of the user that executes the application inside the container.
Named volumes on the other hand work out of the box. A named volume is used, if instead of a host path a handle is used, e.g.
-v myvolume:/path/in/container. This will create the named volume
myvolume, which wil lbe listed by
docker volume ls.