0

I am a docker newbie. I just installed Docker and Docker Desktop as per offical instruction. Soon, I start to have problem like: the Docker Desktop does not show container. I think it's because I haven’t set the contexts same for with and without sudo privilege, according to this post. But I don’t understand why I only have the “default” option for “sudo docker context ls”. Please help me on this. Many thanks!

OS:Ubuntu 20.04.5 LTS

screenshot

1

vimuth
  • 5,064
  • 33
  • 79
  • 116
kenyg
  • 3
  • 2
  • Problem solved, by creating a context for root user using same DOCKER ENDPOINT as normal user. Following instruction here: https://docs.docker.com/engine/context/working-with-contexts/ – kenyg Feb 01 '23 at 01:49

1 Answers1

1

The docker context data is stored in the user's home directory. When you use sudo, that changes users and home directories. Without sudo it might look in /home/yourname/.docker/contexts, but when you switch to root with sudo it also changes home directories and looks in /root/.docker/contexts.

You do not need Docker Desktop on native Linux. Installing Docker (what the Docker documentation now calls "Docker Engine") through your OS's package manager is sufficient. If you are on a single-user system, you can grant your ordinary user access to the Docker socket, but be aware that it's all but trivial to use this access to root the entire host.

When you do uninstall Docker Desktop, there are additional files in your home directory you need to remove

rm -rf $HOME/.docker/desktop
$EDITOR $HOME/.docker/config.json
# and remove `credsStore` and `currentContext`

Once you've done this cleanup, you'll revert to Docker's default behavior of using the $DOCKER_SOCK environment variable, or without that, /var/run/docker.sock. That system-global Docker socket file is the same regardless of which user you are, and it won't be affected by sudo.

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • Thank you for the advice and detailed explanation , David. I totally agree that "I do not need Docker Desktop on native Linux". But I just wan to test out the Desktop. Problem solved, by creating a context for root user using same DOCKER ENDPOINT as normal user. – kenyg Feb 01 '23 at 01:50