0

Nowadays Docker can be installed in at least two ways, which the Docker installer presents as a choice at startup:

  1. a traditional mode (to execute docker from root, or using sudo docker)
  2. also a rootless mode (to execute docker from non-root and non-sudoer)

Some people install Docker "rootless" by mistake in their current user (example: id:gid 1000:1000), thinking that "it's the option to run Docker from the normal user with sudo docker, and then they discover they picked the wrong choice, and they want to rollback to the traditional version (bonus point: without removing that user). They discover it's not compatible anymore with their workflows, for example because the bind mount is always mounted by root:root inside the container (see Permission denied in rootless docker with non-primary group access).

The documentation about how to remove a traditional Docker but it seems not enough for uninstalling the rootless version from an already-existing user while keeping the user (see https://github.com/docker/docker-install/issues/166).

Question:

How do I uninstall "Docker rootless" from an user, keeping that user? for example, in Ubuntu, or Debian-based systems?

Purpose: switch to regular Docker, preserving the user. Thanks!


I tried various opinions from the mentioned issue, for example by changing "Docker context", but for some reason it was not enough to me. Or anyway, I couldn't figure out what was the minimum sequence by which I achieved my goal. I've followed too many tips from that issue. It would be nice to understand the minimum steps, at least in Ubuntu or Debian-based systems.

Extra notes:

10
  • Thanks for any answer. I think this question might be useful to others in the future, more and more, because it happened to a colleague of mine, and we solved it, but we didn't understand very well how. Maybe I will share a solution after I find out. This question is more an attempt to document this case for others, than a concrete question from myself. Commented Mar 28 at 15:12
  • 1
    Delete the non-root user that docker was installed under, including its home directory. If you configured it to store its images somewhere else, remove that directory too. Commented Mar 28 at 15:30
  • 2
    Ah, that's not a fundamentally different installation, that's just a different kind of operation. You don't uninstall, you reconfigure, probably. But now the problem is that you went with the lesser-supported way of using the manual install instead of a simply apt install docker (or apt install docker-ce). If you did it this debian/ubuntu way, uninstallation would just be an apt remove away. For the binary installer… not so much, I guess. Commented Mar 29 at 15:27
  • 1
    Thanks @MarcusMüller - I still don't know a suitable rephrase. I think some people will try to land here with the above title. "How to reconfigure Docker to avoid rootless mode?" or something like that? Edit welcome Commented Mar 29 at 15:35
  • 1
    Unless you've made some spectacularly poor decisions while installing Docker rootless, deleting the docker user will do exactly what you need. Commented Mar 29 at 16:31

1 Answer 1

0

I had this issue today too, very frustrating and none of the suggestions worked but I did resolve it. First of all the comments in that GitHub issue saying "rootless doesn't use system packages" were not correct, docker was installed via apt for me. I don't understand why this issue occurs or why what I did to fix it was necessary, but it was simple enough:

  • Remove docker: sudo apt remove docker* containerd*
  • Restart! After removing docker I still had dockerd-rootless running in the background until a reboot.
  • Reinstall docker from apt packages (I used the https://get.docker.com script)
  • Add DOCKER_HOST=unix:///var/run/docker.sock to .bashrc

Like I said, no clue why DOCKER_HOST needed to be set here. It wasn't present in my env when it was defaulting to rootless, and none of my other servers which have been rooted Docker from the start have it. But it works now, so I hope this helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .