我们在尝试运行docker命令时遇到此错误。例如:
$ 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
因此,我们按照here的步骤进行操作,但问题仍然存在。然后我们看到this问题,在哪里建议
您必须重新启动docker守护进程,否则它不会让成员 组成员来控制docker守护进程
但无法重新启动服务
$ sudo service docker restart
Failed to restart docker.service: Unit docker.service not found.
我们正在使用
$ docker -v
Docker version 18.06.1-ce, build e68fc7a
在
$ 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
docker组已经成功创建,我们是其中的成员
$ grep docker /etc/group
docker:x:1001:siddjain
我们也已经注销并重新登录。我们能够使用sudo
运行docker命令。还有
$ sudo snap services
Service Startup Current Notes
docker.dockerd enabled active -
有人可以帮助我们吗?
答案 0 :(得分:0)
解决方案是使用snap
重新启动docker守护进程(因为这是我们安装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.
之后,我们可以运行docker命令,而无需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:~$
我们的喜悦很短暂,因为当我们尝试运行另一个容器时,我们立即遇到了另一个错误。
mkdir /var/lib/docker: read-only file system
要解决此问题,我们不得不再次卸载并重新安装docker-这次从here所述的官方文档中删除