Docker fails to start after install with "loopback attach failed"
If you run Linux in a VM on Xen, you need to install the kernel and use pygrub (see https://wiki.debian.org/PyGrub) and update to docker version 19.03.0.
install pygrub
1. In your VM execute:
mkdir /boot/grubapt-get install -y linux-image-amd64cat > /boot/grub/menu.lst << EOFdefault 0timeout 2title Debian GNU/Linuxroot (hd0,0)kernel /vmlinuz root=/dev/xvda2 roinitrd /initrd.imgtitle Debian GNU/Linux (recovery mode)root (hd0,0)kernel /vmlinuz root=/dev/xvda2 ro singleinitrd /initrd.imgEOF
2. halt your VM, for example:
xen destroy vm01
3. edit your xen config
for example for your VM /etc/xen/vm01.cfg
in your DOM0 (comment out the first two lines and add the last three):
#kernel = '/boot/vmlinuz-4.9.0-9-amd64'#ramdisk = '/boot/initrd.img-4.9.0-9-amd64'extra = 'elevator=noop'bootloader = '/usr/lib/xen-4.8/bin/pygrub'bootloader_args = [ '--kernel=/vmlinuz', '--ramdisk=/initrd.img', ]
4. start your vm:
xen create /etc/xen/vm01.cfg
I have the same problem in a Debian 9 VM and the same in Debian 8 VM both on the same Debian XEN 4.8 host.
loopback seems not to exist:
# losetup -flosetup: cannot find an unused loop device: No such device
You can create those with
#!/bin/bashensure_loop(){ num="$1" dev="/dev/loop$num" if test -b "$dev"; then echo "$dev is a usable loop device." return 0 fi echo "Attempting to create $dev for docker ..." if ! mknod -m660 $dev b 7 $num; then echo "Failed to create $dev!" 1>&2 return 3 fi return 0}ensure_loop 0ensure_loop 0
But this is just a tip to find the right solution, it didn't solve it completely, now since /dev/loop0
exists, I have the error:
Error opening loopback device: open /dev/loop0: no such device or address[graphdriver] prior storage driver devicemapper failed: loopback attach failed
Update:
I installed apt-get install docker-ce docker-ce-cli containerd.io
like described in the latest docs and now with the latest version:
$ docker --versionDocker version 19.03.0, build aeac9490dc
still the same issue:
failed to start daemon: error initializing graphdriver: loopback attach failed
This is the full log:
level=info msg="Starting up"level=warning msg="failed to rename /var/lib/docker/tmp for background deletion: rename /var/lib/docker/tmp /var/lib/docker/tmp-old: file exists. Deleting synchronously"level=info msg="parsed scheme: \"unix\"" module=grpclevel=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpclevel=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] }" module=grpclevel=info msg="ClientConn switching balancer to \"pick_first\"" module=grpclevel=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0005e8660, CONNECTING" module=grpclevel=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0005e8660, READY" module=grpclevel=info msg="parsed scheme: \"unix\"" module=grpclevel=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpclevel=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] }" module=grpclevel=info msg="ClientConn switching balancer to \"pick_first\"" module=grpclevel=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0007f5b10, CONNECTING" module=grpclevel=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0007f5b10, READY" module=grpclevel=error msg="There are no more loopback devices available."level=error msg="[graphdriver] prior storage driver devicemapper failed: loopback attach failed"failed to start daemon: error initializing graphdriver: loopback attach failed
Update 2:
In the end I found out, that pygrub was missing in the VM, which seems to be a new dependency since some version.
This answer was a dead end path, I added another answer, but I leave this here for other users, that have a different problem to get some hints.