0

Why I am getting this error when executing docker version with non-sudo user. I have installed docker using Script

Output with non-sudo user

docker version
Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:35:18 2023
 OS/Arch:           linux/amd64
 Context:           desktop-linux
Cannot connect to the Docker daemon at unix:///home/cttc/.docker/desktop/docker.sock. Is the docker daemon running?

Output with sudo user

sudo docker version
Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:35:18 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       a61e2b4
  Built:            Fri Jul 21 20:35:18 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

My user is part of a docker group. Previously, there is an installation of docker desktop but I have uninstalled it.

  • What is the ouput of `docker context` for your user and the sudo-user? – CloudWatcher Aug 29 '23 at 11:48
  • After the installation and adding the user to `docker group` did you logout/login with that user? Step 3 at https://docs.docker.com/engine/install/linux-postinstall/ – Ron Aug 29 '23 at 12:22
  • @Ron yes I restarted the PC as well. – Waleed Akbar Aug 31 '23 at 12:51
  • @CloudWatcher **docker context** Usage: docker context COMMAND Manage contexts Commands: create Create a context export Export a context to a tar archive FILE or a tar stream on STDOUT. import Import a context from a tar or zip file inspect Display detailed information on one or more contexts ls List contexts rm Remove one or more contexts show Print the name of the current context update Update a context use Set the current docker context **sudo dokcer context** sudo: dokcer: command not found – Waleed Akbar Aug 31 '23 at 12:53
  • Sorry, I meant `docker context show`. It looks like your users might have different contexts. – CloudWatcher Aug 31 '23 at 13:24
  • @CloudWatcher **docker context show** desktop-linux **sudo docker context show** default – Waleed Akbar Sep 01 '23 at 09:40
  • thank you @CloudWatcher. Yes. My user is in the different context, I changed the context and it works... – Waleed Akbar Sep 01 '23 at 09:48

1 Answers1

0

Since my suspicions in the comments were confirmed, I am here writing it up again.

The docker version command put out the context for the non-root user as
Context: desktop-linux
and for the root user as
Context: default
This discrepancy put me on the right path. Using docker context show intuitively shows the current docker context in which the program works. These contexts were confirmed to be different for the different users.

Docker contexts can be switched with docker context use <context name>, so here default or desktop-linux.

CloudWatcher
  • 181
  • 1
  • 11