22

Docker used to work, but now it gives an error whenever running a container:

docker: Error response from daemon: failed to create endpoint - failed to add host
  • Example:
    docker run -it debian
    
  • Resulting Error:
    docker: Error response from daemon: failed to create endpoint dazzling_ptolemy on network bridge:
            failed to add the host (veth1e8eb9b) <=> sandbox (veth73c911f) pair interfaces:
            operation not supported
    

I have restarted Docker using

systemctl restart docker

I also did a network prune

docker network prune

Nothing seemed to work. What can be the cause?

AdminBee
  • 22,803
Machiavelli
  • 321
  • 1
  • 2
  • 5
  • 2
    If anybody finds this question because they upgraded their Raspberry Pi to Ubuntu 21.10 and docker stopped working, see the release notes at https://discourse.ubuntu.com/t/impish-indri-release-notes/21951 They say you can work around the problem via sudo apt install linux-modules-extra-raspi – Mark Allen Oct 29 '21 at 21:10
  • 1
    This deserves a full answer (not a comment), and answered my question. Thank you! – Jon Thomason Nov 25 '21 at 01:16

5 Answers5

20

To provide a more specific answer than the others.

The reboot works because the source of this issue is missing kernel module files for your active kernel.

Say you're running kernel linux-image-4.19.0-13-amd64. This package installs the various binary kernel module files under /lib/modules/4.19.0-13-amd64. When you load up a Docker container, it loads several of these modules dynamically, especially if this is the first container you've started since last boot.

Now let's say you upgrade your kernel to linux-image-4.19.0-14-amd64. At this point, pending a reboot, you're still running linux-image-4.19.0-13-amd64 and if you start a Docker container, it will load the 4.19.0-13 modules. This should work fine.

The issue comes if you then remove the linux-image-4.19.0-13-amd64 package before rebooting (and ignore the dire warning about "removing a running kernel" as I am apt to do). If you then try to load these modules, it will fail because the binary files in /lib/modules for the running kernel are now missing. This is why a reboot fixes it - on reboot, you boot into the newer kernel that has these files for it.

Hopefully this helps clarify, as I just ran into the issue myself and needed to figure it out rather than reboot the system.

17

I haven't taken the time to figure out why, but you should just need to reboot your machine; it worked for me.

A search for the error on github came up with this, which links to this github issue from a while ago: https://github.com/moby/moby/issues/15341#issuecomment-218930712

Eric
  • 187
  • 3
  • 1
    Yea, I forgot to update this but I restarted and it worked like a charm. Not sure why this happens. – Machiavelli Apr 29 '17 at 07:30
  • @Machiavelli If this answer solves your issue, please consider accepting the answer. – Kusalananda Apr 29 '17 at 08:32
  • 4
    For me this is caused by updating my kernel. I use an operating system that has a rolling release, in which kernel updates happen somewhat frequently. There's always a chance when i update my system that the kernel is updated and a reboot will be necessary in order for docker networking to work again. I hope this helps those who may wonder what causes this. I would love to find a way to avoid the restart. – Patrick Motard Apr 27 '18 at 16:06
  • 1
    This is not a solution, but a workaround. – Nils Magnus Jul 26 '18 at 14:14
  • 10
    Things like this make me want to leave computers behind and look into woodcutting – domenukk Apr 28 '19 at 04:28
  • 2
    In my experience, this happens because I updated my system but I forgot to restart to load the new kernel and reinitialize the networking system. I think it's trying to load something that's for the new, non-running kernel. Just a thought. – Nathan Sep 30 '19 at 17:23
3

The cause may be a kernel update. After a kernel update you need to restart and docker should work as before.

sjdh
  • 231
1

sudo modprobe veth fixed this for me.

0

For me, enabling virtualization on the CPU solved the issue. Ryzen 5800 on x570 chipset.

  1. Press 'Del' or 'F2' in the keyboard after power on, then press 'F7' to enter into Advanced Mode(ROG series motherboard can directly enter into Advanced Mode, no need to press 'F7'):

  2. Click [Advanced] - [CPU Configuration]:

  3. Please set [SVM Mode] as [Enabled]:

Details here https://www.asus.com/support/FAQ/1038245/

  • 1
    Welcome to the site, and thank you for your contribution. You may want to expand your answer by explaining what steps you took to enable the virtualization. – AdminBee Jan 05 '22 at 13:04