Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 3 tasks
ghost opened this issue Sep 29, 2022 · 18 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Sep 29, 2022

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID:

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

  • Linux distro: Pop OS, Ubuntu
  • Distro version: 22.04 LTS
  • Docker Desktop Version: The latest.

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 ghost changed the title Docker Desktop for Linux (Docker Compose with Volumes) are set to root and not a custom user for a specific build. Docker Desktop for Linux (Docker Compose with Volumes) are set to root and not a custom user for a specific user. Sep 29, 2022
@ghost
Copy link
Author

ghost commented Sep 29, 2022

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

@aiordache
Copy link
Collaborator

@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
Copy link
Author

ghost commented Oct 21, 2022

@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
Copy link
Collaborator

@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
Copy link

@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
Copy link
Author

ghost commented Feb 17, 2023

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

@AlexCostello91
Copy link

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

@liminspace
Copy link

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
Copy link

jacksontong commented May 8, 2023

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
Copy link

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
Copy link

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

@this-santhoshss
Copy link

this-santhoshss commented May 13, 2023

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
Copy link

fouteox commented Jun 13, 2023

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

cytopia/devilbox#963 (comment)

@rfay
Copy link

rfay commented Aug 11, 2023

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
Copy link

nolany commented Oct 4, 2023

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
Copy link

rubensa commented Feb 28, 2024

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
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

15 participants