2

I have tried to upgrade docker, and received an error, so I did a reinstall. However, the issue persists. The folder it fails to stat does indeed not exist. What can I do to fix this issue?

I could of course simply create that directory and hope it was not a sign of something being terribly broken which will haunt me later. But I'd like to have input from somebody who knows more than I.

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 seems to be installed:

generic@motorbrot:~$ which docker
/usr/bin/docker
generic@motorbrot:~$ docker --version
Docker version 20.10.2, build 20.10.2-0ubuntu1~18.04.2

But when I run sudo apt upgrade it shows it as "Not fully installed or removed".

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

System

I'm on 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

Trying to use docker

but I cannot start the daemon. it says it is "masked".

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.

Creating directory /var/lib/docker

I tried creating that directory that it failed to stat (after making a zfs snapshot so that I could rollback in the worst case). Now it is complaining that docker.migrating/docker is not empty.

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)

And even if I remove that directory, I get problems:

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)

The Post-Install Script

It's located at /var/lib/dpkg/info/docker.io.postinst according to this answer, and it seems to me that it deletes the directory even if I create it ahead of time, then complains that it does not exist.

A quick look at it shows that it does special handling for ZFS, so I should point out that I am indeed running on ZFS on root.

Apt Purge

I'm going somewhat nuclear now, I rarely use docker anyway. I have removed all the docker datasets that were annyoing me in zfs list anyway:

for dataset in $(zfs list | grep legacy | cut -f1); do zfs destroy -R "$dataset" || true ; done

and also did a purge

$ 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

There remains a file /etc/docker/key.json

Reinstall again, get a new issue:

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

1 Answer 1

4

I have messed around carelessly with this, and now docker is working again for me! Beware that my approach was quite nuclear!

  • sudo apt remove docker.io
  • sudo apt purge docker.io
  • in case /var/lib/docker or /var/lib/docker.migating still exist, remove them
  • in case zfs list | grep legacy shows any docker datasets, remove them all with for dataset in $(zfs list | grep legacy | cut -f1); do zfs destroy -R "$dataset" || true ; done Again, this is a risky command that could also destroy other things! Be sure you don't care about dataloss or know what you are doing. I don't even know if that step was required.
  • sudo apt install docker.io --> Get an Error
  • sudo systemctl restart docker

Now it's working again for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .