查看docker是否运行
时间: 2024-01-05 07:12:32 浏览: 144
可以使用以下命令来检查 Docker 是否正在运行:
```
sudo systemctl status docker
```
如果 Docker 正在运行,输出应该类似于以下内容:
```
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-09-27 10:07:55 UTC; 2 days ago
Docs: https://docs.docker.com
Main PID: 2322 (dockerd)
Tasks: 34
Memory: 82.3M
CPU: 11min 32.116s
CGroup: /system.slice/docker.service
├─2322 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─2816 containerd --config /var/run/containerd/containerd.toml --log-level info
├─5349 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.17.0.2 -container-port 80
└─5356 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 443 -container-ip 172.17.0.2 -container-port 443
```
如果 Docker 没有运行,则输出应该类似于以下内容:
```
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2021-09-27 10:05:22 UTC; 2 days ago
Docs: https://docs.docker.com
Process: 1958 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 1958 (code=exited, status=1/FAILURE)
```
如果 Docker 没有运行,可以使用以下命令来启动它:
```
sudo systemctl start docker
```
阅读全文