问题

问题

问题

我可以手动运行 docker

sudo dockerd或者/etc/init.d/docker start

但不是作为一种服务。

系统

Linux g4070 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Lin

Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:18:20 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:16:15 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0


Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)

Server:
 Containers: 5
  Running: 0
  Paused: 0
  Stopped: 5
 Images: 9
 Server Version: 20.10.5
 Storage Driver: devicemapper
  Pool Name: docker-253:0-54002895-pool
  Pool Blocksize: 65.54kB
  Base Device Size: 10.74GB
  Backing Filesystem: ext4
  Udev Sync Supported: true
  Data file: /dev/loop3
  Metadata file: /dev/loop21
  Data loop file: /var/lib/docker/devicemapper/devicemapper/data
  Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
  Data Space Used: 368MB
  Data Space Total: 107.4GB
  Data Space Available: 107GB
  Metadata Space Used: 17.9MB
  Metadata Space Total: 2.147GB
  Metadata Space Available: 2.13GB
  Thin Pool Minimum Free Space: 10.74GB
  Deferred Removal Enabled: true
  Deferred Deletion Enabled: true
  Deferred Deleted Device Count: 0
  Library Version: 1.02.167 (2019-11-30)
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-66-generic
 Operating System: Ubuntu 20.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.674GiB
 Name: g4070
 ID: 7LHW:SAWD:UW57:6FWM:MISB:LKH4:6NIA:ZNWQ:GJPA:XXLK:A3EI:7UVH
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No cpu shares support
WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release.
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
         Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.

运行 Docker

我尝试过几种方式运行 docker,但只能手动完成。

输出sudo service docker start

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.

输出sudo systemctl start docker

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.

安装新系统时自动启动失败

sudo apt install cgroupfs-mount
...
Unpacking cgroupfs-mount (1.4) ...
Setting up docker-ce (5:20.10.5~3-0~ubuntu-focal) ...
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/docker.service.d
             └─docker.conf
     Active: activating (auto-restart) (Result: exit-code) since Wed 2021-03-03 12:23:21 +0545; 6ms ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 86196 ExecStart=/usr/bin/dockerd --graph=/mnt/docker-data --storage-driver=overlay --storage-opt=dm.basesize=30G (code=exited, status=1/F
AILURE)
   Main PID: 86196 (code=exited, status=1/FAILURE)
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of docker-ce-rootless-extras:
 docker-ce-rootless-extras depends on docker-ce; however:
  Package docker-ce is not configured yet.

dpkg: error processing package docker-ce-rootless-extras (--configure):
 dependency problems - leaving unconfigured
Setting up cgroupfs-mount (1.4) ...
No apport report written because the error message indicates it's a follow-up error from a previous failure.
                                                                                                            Processing triggers for man-db (2.9.1-1) .
..
Processing triggers for systemd (245.4-4ubuntu3.4) ...
Errors were encountered while processing:
 docker-ce
 docker-ce-rootless-extras
E: Sub-process /usr/bin/dpkg returned an error code (1)

输出journactl -xe

-- The unit docker.service has entered the 'failed' state with result 'exit-code'.
Mar 03 12:27:09 g4070 systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: A start job for unit docker.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit docker.service has finished with a failure.
-- 
-- The job identifier is 5797 and the job result is failed.

手动,输出sudo dockerd

INFO[2021-03-03T12:45:51.199161171+05:45] Starting up                                  
INFO[2021-03-03T12:45:51.204120548+05:45] detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/resolv.conf 
INFO[2021-03-03T12:45:51.205022694+05:45] parsed scheme: "unix"                         module=grpc
INFO[2021-03-03T12:45:51.205048857+05:45] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2021-03-03T12:45:51.205083723+05:45] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2021-03-03T12:45:51.205099311+05:45] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2021-03-03T12:45:51.206048454+05:45] parsed scheme: "unix"                         module=grpc
INFO[2021-03-03T12:45:51.206069262+05:45] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2021-03-03T12:45:51.206088901+05:45] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2021-03-03T12:45:51.206101916+05:45] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2021-03-03T12:45:51.289599183+05:45] ignoring event                                container=784e314cf411d8f314777582559876069f3bbf8d86ce88923daa4d3db6a3a5f9 module=libcontainerd namespace=plugins.moby topic=/tasks/delete type="*events.TaskDelete"
WARN[2021-03-03T12:45:52.432289971+05:45] Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man dockerd` to refer to dm.thinpooldev section.  storage-driver=devicemapper
WARN[2021-03-03T12:45:52.485540322+05:45] Base device already exists and has filesystem ext4 on it. User specified filesystem  will be ignored.  storage-driver=devicemapper
INFO[2021-03-03T12:45:52.542597632+05:45] [graphdriver] using prior storage driver: devicemapper 
WARN[2021-03-03T12:45:52.542678785+05:45] [graphdriver] WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release 
WARN[2021-03-03T12:45:52.668450021+05:45] Your kernel does not support swap memory limit 
WARN[2021-03-03T12:45:52.668523341+05:45] Your kernel does not support CPU realtime scheduler 
WARN[2021-03-03T12:45:52.668557411+05:45] Your kernel does not support cgroup blkio weight 
WARN[2021-03-03T12:45:52.668583887+05:45] Your kernel does not support cgroup blkio weight_device 
INFO[2021-03-03T12:45:52.669019536+05:45] Loading containers: start.                   
INFO[2021-03-03T12:45:54.319361138+05:45] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address 
INFO[2021-03-03T12:45:54.977967148+05:45] Loading containers: done.                    
INFO[2021-03-03T12:45:55.018784152+05:45] Docker daemon                                 commit=363e9a8 graphdriver(s)=devicemapper version=20.10.5
INFO[2021-03-03T12:45:55.018938010+05:45] Daemon has completed initialization          
INFO[2021-03-03T12:45:55.066237573+05:45] API listen on /var/run/docker.sock 

尝试解决

卸载并重新安装

我尝试过卸载并重新安装。卸载后甚至重新启动了系统。我可以手动启动,但不能作为服务启动。

启动/停止 cgroup 的尝试失败

由于列出了一些警告cgroups,我甚至尝试了这种方法,但没有成功。

service docker stop
service containerd stop
cgroupfs-umount
cgroupfs-mount
service containerd start
service docker start

嗯,我没法sudo cgroupfs-umount

rmdir: failed to remove 'blkio': Read-only file system
rmdir: failed to remove 'cpu': Read-only file system
rmdir: failed to remove 'cpu,cpuacct': Read-only file system
rmdir: failed to remove 'cpuacct': Read-only file system
rmdir: failed to remove 'cpuset': Read-only file system
rmdir: failed to remove 'devices': Read-only file system
rmdir: failed to remove 'freezer': Read-only file system
rmdir: failed to remove 'hugetlb': Read-only file system
rmdir: failed to remove 'memory': Read-only file system
rmdir: failed to remove 'net_cls': Read-only file system
rmdir: failed to remove 'net_cls,net_prio': Read-only file system
rmdir: failed to remove 'net_prio': Read-only file system
rmdir: failed to remove 'perf_event': Read-only file system
rmdir: failed to remove 'pids': Read-only file system
rmdir: failed to remove 'rdma': Read-only file system
rmdir: failed to remove 'systemd': Read-only file system

停止/禁用 Docker 服务

停止 docker 时抛出一条警告消息。

sudo /etc/init.d/docker stop或者sudo service docker stop或者sudo systemctl stop docker

Stopping docker (via systemctl): docker.serviceWarning: Stopping docker.service, but it can still be activated by: docker.socket

sudo /etc/init.d/docker status

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2021-03-31 16:43:40 +0545; 6s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 107187 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
   Main PID: 107187 (code=exited, status=0/SUCCESS)

警告意味着如果我们在 docker 服务未运行时尝试连接到 docker 套接字,则 systemd 将自动启动 docker。可以通过删除 docker.socket 和 docker.service 文件来抑制它,但这可能无助于重新运行 docker,因此必须这样做

当我尝试通过以下方式禁用 docker 时抛出消息sudo systemctl disable docker

Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable docker

通过取消屏蔽 docker 服务删除了警告消息。

屏蔽服务可防止服务手动或自动启动,这是禁用的更强版本。屏蔽禁用将删除指定单元文件的所有符号链接。

systemctl unmask docker.service
systemctl unmask docker.socket
systemctl list-unit-files | grep docker // Check the status

相关内容