我通过 Visual Studio Code (VSCode,版本1.66)远程连接到学校服务器(Ubuntu 20.04.2 LTS),执行一些任务。今天,我按照 docker.com 的步骤 (https://docs.docker.com/engine/install/ubuntu/) 在 Ubuntu 上安装了 Docker 引擎。
当我完成所有步骤后运行 sudo docker run hello-world
来验证 Docker 引擎是否正确安装并运行 hello-world
镜像时,出现了以下错误:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
接下来我检查了 docker version
,它显示
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:48:02 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
接下来查看 sudo docker info
,它显示了
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
我按照这个教程卸载并重新安装了docker,但仍然显示出错,我觉得需要按照docker的服务器端进行操作,但我不知道该怎么做?
这是历史记录:
root@yp:~# sudo apt-get remove docker docker-engine docker.io containerd runc
...
root@yp:~# sudo apt-get update
...
root@yp:~# sudo apt-get install \
> ca-certificates \
> curl \
> gnupg \
> lsb-release
...
root@yp:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
...
root@yp:~# echo \
> "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
...
root@yp:~# sudo apt-get update
...
root@yp:~# sudo apt-get install docker-ce docker-ce-cli containerd.io
...
root@yp:~# sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
root@yp:~# systemctl start docker
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
- Yangroot@yp:~# sudo service docker start
,* Starting Docker: docker
,但是它没有起作用。 - Yang