0

we are getting this error while trying to run docker commands. E.g.:

$ docker image ls
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/json: dial unix /var/run/docker.sock: connect: permission denied

So we followed the steps here but the problem remains. Then we saw this question where it is advised

You have to restart the docker daemon, otherwise it won't let members of the docker group to control the docker daemon

but are having trouble restarting the service

$ sudo service docker restart
Failed to restart docker.service: Unit docker.service not found.

we are using

$ docker -v
Docker version 18.06.1-ce, build e68fc7a

on

$ uname -a
Linux jnj 4.15.0-1036-azure #38-Ubuntu SMP Fri Dec 7 02:47:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

the docker group has been successfully created and we are member of it

$ grep docker /etc/group
docker:x:1001:siddjain

Also we did log out and log back in. we are able to run docker commands with sudo. Also

$ sudo snap services
Service         Startup  Current  Notes
docker.dockerd  enabled  active   -

can anyone help us?

morpheus
  • 18,676
  • 24
  • 96
  • 159

1 Answers1

1

The solution was to restart docker daemon using snap (since that is how we installed docker)

siddjain@jnj:~$ sudo snap stop docker
Stopped.
siddjain@jnj:~$ snap start docker
error: access denied (try with sudo)
siddjain@jnj:~$ sudo snap start docker
Started.

After that we are able to run docker commands without having to sudo

siddjain@jnj:~$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

siddjain@jnj:~$ 

Our joy was shortlived as we immediately ran into another error after this one when we tried to run another container.

mkdir /var/lib/docker: read-only file system

To fix it we had to uninstall and reinstall docker again - this time from the official documentation as described here

morpheus
  • 18,676
  • 24
  • 96
  • 159