Linux容器-Docker服务运维

查看 docker 服务状态

  • 查看系统级服务状态
    sudo systemctl status docker

    可以查看到 docker service 文件位置

    walkerjun@walkerjun:~$ sudo systemctl status docker
    [sudo] walkerjun 的密码: 
    ○ docker.service - Docker Application Container Engine
         Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
         Active: inactive (dead) since Sun 2022-06-12 18:07:57 CST; 17min ago
    TriggeredBy: ○ docker.socket
           Docs: https://docs.docker.com
        Process: 209698 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
       Main PID: 209698 (code=exited, status=0/SUCCESS)
            CPU: 1.159s
    
  • 查看用户级服务状态
    systemctl --user status docker
    walkerjun@walkerjun:~$ systemctl --user status docker
    ● docker.service - Docker Application Container Engine (Rootless)
         Loaded: loaded (/home/walkerjun/.config/systemd/user/docker.service; enabled; vendor preset: enabled)
         Active: active (running) since Sun 2022-06-12 18:12:46 CST; 15min ago
           Docs: https://docs.docker.com/go/rootless/
       Main PID: 231519 (rootlesskit)
          Tasks: 47
         Memory: 89.8M
            CPU: 3.463s
         CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/docker.service
                 ├─231519 rootlesskit --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin >
                 ├─231530 /proc/self/exe --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=built>
                 ├─231548 slirp4netns --mtu 65520 -r 3 --disable-host-loopback --enable-sandbox --enable-seccomp 231530 tap0
                 ├─231555 dockerd
                 └─231578 containerd --config /run/user/1000/docker/containerd/containerd.toml --log-level info
    

停止docker 服务

仅仅是 sudo service docker stop 不够,有以下提示
image

  • 停止 docker 使用以下命令
    sudo systemctl stop docker.service
    sudo systemctl stop docker.socket
    
  • 停止用户docker服务
    sudo systemctl --user stop docker.service