docker / desktop-linux

Bug reports for Docker Desktop for Linux
https://docs.docker.com/desktop/linux/
79 stars 5 forks source link

Docker Desktop for Linux (Docker Compose with Volumes) are set to root and not a custom user for a specific user. #81

Open ghost opened 2 years ago

ghost commented 2 years ago

Expected behavior

As a LInux user, I have tried using Docker Desktop on Linux and I have found some interesting things going on. Please note that I don't have issues when using Docker Engine for Linux. When I use my own docker images which contains by default an actual user for example user1 this user user1 is the main user for the container. I basically do not use root as my main user in any of my images. When I do a bash, I can use user1 to do sudo or any commands that needs priviledges.

i also found that when using docker compose with a few volumes... the expect behavior should be that these volumes are set to user1 as user and this user1 can create, modify the volumes.. this can be done in Docker Engine fine.

Actual behavior

When using Docker Desktop for Linux. I am not able to mount these volumes properly with my custom user (user1) instead, it keeps default to root user instead of my user1. When you use Docker Desktop, is this application automatically set to root by default. Can this be change so that if a docker image does not use root whatsoever.

Information

Steps to reproduce the behavior

Please use docker compose for this and create volumes, but remember the docker image must use a custom user and shouldn't use root for this purpose. If you need a custom image.. I have build one that u can pull down benlumia007/ubuntu:22.04

Again when using docker compose up -d, enter to bash and navigate to the volumes that docker compose specified. You should see that rather than the custom user1, it is under root and will give you permission denied.

ghost commented 2 years ago

I build an image benlumia007/ubuntu:22.04, this image is already been configured to use docker as an user rather than root.

aiordache commented 2 years ago

@benlumia007 When user1 runs a Docker Desktop container, its permissions are mapped to the root user inside the container. Not to be confused with the root user outside the container, more details on filesharing can be found at https://docs.docker.com/desktop/faqs/linuxfaqs/#how-do-i-enable-file-sharing and on the use of a VM at https://docs.docker.com/desktop/faqs/linuxfaqs/#why-does-docker-desktop-for-linux-run-a-vm

ghost commented 2 years ago

@aiordache I understand that, the problem is that my docker itself is not running root inside the container.. so this makes it harder for me to use my own custom images if I use the Desktop version of Docker for linux. So the way you are saying that no matter what if users are using the Docker Desktop for Linux are always going to be mapped to root user inside the container.

I would have then to use Docker Engine for my own custom projects. I am not against having root as the main user but that is defintely not the safest in my opinion.

aiordache commented 2 years ago

@benlumia007 Indeed it's not. We are currently looking to fix this behaviour, we'll let you know once we have a build for testing.

angelbt91 commented 1 year ago

@benlumia007 Indeed it's not. We are currently looking to fix this behaviour, we'll let you know once we have a build for testing.

Any news regarding this by any chance? I'm experiencing the same problem. Thanks a lot!

ghost commented 1 year ago

It's still happening so I don't know. I don't work for or with docker project.

AlexCostello91 commented 1 year ago

I experienced this as well today when trying out Docker Desktop on Fedora.

liminspace commented 1 year ago

I use docker for desktop on macos and it mounts a volume using host user 501/20. When I'm trying to use the same project on Ubuntu, it mounts using root user instead of my 1000/1000. Is there a way to fix that?

jacksontong commented 1 year ago

I use docker for desktop on macos and it mounts a volume using host user 501/20. When I'm trying to use the same project on Ubuntu, it mounts using root user instead of my 1000/1000. Is there a way to fix that?

I would like to know how to solve this as well.

kashifm14 commented 1 year ago

I am also running into the same issue. One of the ideas behind Docker Desktop is to make usage consistent between different OSes. Using VirtioFS leads to better performance but diverges the functionality of Docker desktop in Linux from Windows or Mac. That is not ideal.

While using the docker desktop we get a different way in how the volumes are mounted, in that the host user files are mounted as root (0)user inside the container. But when we use default docker, we do not run into such issues, the host uid is the same as the container user uid when we mount the volume.

Is there any plan to fix this inconsistency?

Interdictor commented 1 year ago

Same problem here with Docker desktop v4.19.0 and ubuntu 22.04

this-santhoshss commented 1 year ago

I am also facing the same problem with Docker Desktop version 4.19.0 (106363) and Ubuntu 22.04. Is there any any way to get the docker team to notice this bug? This has been open since last year :(

fouteox commented 1 year ago

See this solution for Docker Desktop OR Docker Engine rootless mode, works fine :

https://github.com/cytopia/devilbox/issues/963#issuecomment-1438939653

rfay commented 1 year ago

The interesting thing is that docker-ce (Docker Engine) works fine and always has, And Docker Desktop for Mac and Windows both work fine without this deficiency. Docker Desktop for Linux offers no particular value over docker-ce anyway. DDEV detects and warns about Docker Desktop for Linux; because of this it's impossible to use.

nolany commented 1 year ago

Just wanted to bump this. My company is moving over to Docker Desktop and I happen to be the only one using Ubuntu 22 and ran into this as well. I cannot use Docker Desktop at all because of this. Changing back to docker-ce immediately allowed me to interact with the volumes once the containers were running.

rubensa commented 8 months ago

So trying to find the root cause of the problem...

Looks like Docker Desktop for Linux is using QEmu for setting up the Virtual Machine running the Docker daemon. To share a host folder with the VM, it uses VirtioFS.

I suppose that it uses libvirt under the hood that, when run unprivileged, as also stated here, maps the current user on the host to the root user (ID 0) in the guest.

With virtiofsd, if the option --uid-map is not provided, virtiofsd will set up a 1-to-1 mapping for current uid.

So I think that it might be possible to allow this on Docker Desktop for Linux.

@aiordache Is still someone looking at this?

muncherelli commented 6 months ago

i love this part of the docker desktop FAQ:

Why does Docker Desktop for Linux run a VM? Docker Desktop for Linux runs a Virtual Machine (VM) for the following reasons:

To ensure that Docker Desktop provides a consistent experience across platforms.

what a load of bullshit.

joejo-waywise commented 5 months ago

Just dropping a note that this is STILL an issue a year and a half plus on and we have no way to get around it at all.