[root@liuawen local]# docker -v
Docker version 1.13.1, build cccb291/1.13.1
[root@liuawen local]# 

启动、关闭与重启docker时

[root@liuawen ~]# service docker stop
Redirecting to /bin/systemctl stop docker.service
[root@liuawen ~]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@liuawen ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@liuawen ~]# 

出现这个Redirecting to /bin/systemctl start docker.service。

https://docs.docker.com/config/daemon/systemd/

在这里插入图片描述

大多数Linux发行版本使用systemctl启动服务,如果不是那就尝试使用下service来启动。

我的环境是使用这个systemctl start docker来启动。

查看下ps -ef | grep "docker" docker启动了

启动docker:systemctl start docker

停止docker:systemctl stop docker

重启docker:systemctl restart docker

[root@liuawen local]# systemctl start docker
[root@liuawen local]# ps -ef | grep "docker"
root     25171     1  0 11:14 ?        00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root     25177 25171  0 11:14 ?        00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root     25887 21199  0 11:24 pts/2    00:00:00 grep --color=auto docker
[root@liuawen local]# systemctl stop docker
[root@liuawen local]# ps -ef | grep "docker"
root     25910 21199  0 11:24 pts/2    00:00:00 grep --color=auto docker
[root@liuawen local]# systemctl restart docker
[root@liuawen local]# ps -ef | grep "docker"
root     25960     1  2 11:24 ?        00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root     25966 25960  0 11:24 ?        00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root     26063 21199  0 11:25 pts/2    00:00:00 grep --color=auto docker
[root@liuawen local]# 

使用systemctl 来启动、停止、重启docker都可以了。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐