我尝试升级docker,但收到错误,所以我重新安装了。但是,问题仍然存在。它无法统计的文件夹确实不存在。我能做些什么来解决这个问题?
我当然可以简单地创建该目录,并希望它不是严重损坏的迹象,以后会困扰我。但我希望得到比我了解更多的人的意见。
generic@motorbrot:~$ sudo apt-get install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
aufs-tools btrfs-progs debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
docker.io
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/36.9 MB of archives.
After this operation, 192 MB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package docker.io.
(Reading database ... 539898 files and directories currently installed.)
Preparing to unpack .../docker.io_20.10.2-0ubuntu1~18.04.2_amd64.deb ...
Unpacking docker.io (20.10.2-0ubuntu1~18.04.2) ...
Setting up docker.io (20.10.2-0ubuntu1~18.04.2) ...
mv: cannot stat '/var/lib/docker': No such file or directory
dpkg: error processing package docker.io (--configure):
installed docker.io package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
docker.io
E: Sub-process /usr/bin/dpkg returned an error code (1)
Docker 似乎已安装:
generic@motorbrot:~$ which docker
/usr/bin/docker
generic@motorbrot:~$ docker --version
Docker version 20.10.2, build 20.10.2-0ubuntu1~18.04.2
但是当我运行sudo apt upgrade
它时,它显示为“未完全安装或删除”。
generic@motorbrot:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up docker.io (20.10.2-0ubuntu1~18.04.2) ...
mv: cannot stat '/var/lib/docker': No such file or directory
dpkg: error processing package docker.io (--configure):
installed docker.io package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
docker.io
E: Sub-process /usr/bin/dpkg returned an error code (1)
generic@motorbrot:~/algolab$ dpkg -s docker.io | grep Status
Status: install ok half-configured
系统
我在 Ubuntu 18.04
$ uname -a
Linux motorbrot 5.4.0-72-generic #80~18.04.1-Ubuntu SMP Mon Apr 12 23:26:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
尝试使用码头工人
但我无法启动守护进程。它说它是“蒙面的”。
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
generic@motorbrot:~/algolab$ sudo systemctl docker start
Unknown operation docker.
generic@motorbrot:~/algolab$ sudo service docker start
Failed to start docker.service: Unit docker.service is masked.
generic@motorbrot:~/algolab$ sudo systemctl unmask docker
Removed /etc/systemd/system/docker.service.
generic@motorbrot:~/algolab$ sudo systemctl start docker
Failed to start docker.service: Unit docker.socket is masked.
创建目录/var/lib/docker
我尝试创建它无法统计的目录(在制作 zfs 快照之后,以便在最坏的情况下可以回滚)。现在它在抱怨docker.migrating/docker
不是空的。
generic@motorbrot:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up docker.io (20.10.2-0ubuntu1~18.04.2) ...
mv: cannot move '/var/lib/docker' to '/var/lib/docker.migrating/docker': Directory not empty
dpkg: error processing package docker.io (--configure):
installed docker.io package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
docker.io
E: Sub-process /usr/bin/dpkg returned an error code (1)
即使我删除了那个目录,我也会遇到问题:
generic@motorbrot:~$ sudo rm -r /var/lib/docker.migrating/docker
generic@motorbrot:~$ sudo mkdir /var/lib/docker
generic@motorbrot:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up docker.io (20.10.2-0ubuntu1~18.04.2) ...
mv: target '/var/lib/docker/' is not a directory
dpkg: error processing package docker.io (--configure):
installed docker.io package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
docker.io
E: Sub-process /usr/bin/dpkg returned an error code (1)
安装后脚本
它位于/var/lib/dpkg/info/docker.io.postinst
根据this answer,在我看来,即使我提前创建了目录,它也会删除目录,然后抱怨它不存在。
快速浏览一下它会发现它对 ZFS 进行了特殊处理,所以我应该指出我确实在 root 上运行在 ZFS 上。
易于清除
我现在有点核,反正我很少使用 docker。无论如何,我已经删除了所有困扰我的 docker 数据集 zfs list
:
for dataset in $(zfs list | grep legacy | cut -f1); do zfs destroy -R "$dataset" || true ; done
还做了一次清洗
$ sudo apt purge docker.io
generic@motorbrot:~$ sudo apt purge docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
bridge-utils cgroupfs-mount containerd pigz runc ubuntu-fan
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
docker.io*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 192 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 540125 files and directories currently installed.)
Removing docker.io (20.10.2-0ubuntu1~18.04.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
(Reading database ... 539920 files and directories currently installed.)
Purging configuration files for docker.io (20.10.2-0ubuntu1~18.04.2) ...
dpkg: warning: while removing docker.io, directory '/etc/docker' not empty so not removed
还有一个文件/etc/docker/key.json
重新安装,出现新问题:
generic@motorbrot:~$ sudo apt install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
aufs-tools btrfs-progs debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
docker.io
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/36.9 MB of archives.
After this operation, 192 MB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package docker.io.
(Reading database ... 539920 files and directories currently installed.)
Preparing to unpack .../docker.io_20.10.2-0ubuntu1~18.04.2_amd64.deb ...
Unpacking docker.io (20.10.2-0ubuntu1~18.04.2) ...
Setting up docker.io (20.10.2-0ubuntu1~18.04.2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
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)
Active: activating (auto-restart) (Result: exit-code) since Fri 2021-04-23 14:31:06 CEST; 3ms ago
Docs: https://docs.docker.com
Process: 32306 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 32306 (code=exited, status=1/FAILURE)
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
generic@motorbrot:~$ sudo systemctl restart docker
我不小心弄乱了这个,现在 docker 又为我工作了!请注意,我的方法很核!
sudo apt remove docker.io
sudo apt purge docker.io
/var/lib/docker
或/var/lib/docker.migating
仍然存在,删除它们zfs list | grep legacy
显示任何 docker 数据集,请使用for dataset in $(zfs list | grep legacy | cut -f1); do zfs destroy -R "$dataset" || true ; done
Again 将它们全部删除,这是一个危险的命令,也可能破坏其他东西!确保您不关心数据丢失或知道您在做什么。我什至不知道是否需要这一步。sudo apt install docker.io
--> 得到一个错误sudo systemctl restart docker
现在它又为我工作了。