19

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?

2
  • 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 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, 2021 at 21:10
  • 1
    This deserves a full answer (not a comment), and answered my question. Thank you! Nov 25, 2021 at 1:16

5 Answers 5

19

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.

15

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

6
  • 1
    Yea, I forgot to update this but I restarted and it worked like a charm. Not sure why this happens. Apr 29, 2017 at 7:30
  • 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. Apr 27, 2018 at 16:06
  • 1
    This is not a solution, but a workaround. Jul 26, 2018 at 14:14
  • 10
    Things like this make me want to leave computers behind and look into woodcutting
    – domenukk
    Apr 28, 2019 at 4: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, 2019 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.

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
  • 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 5, 2022 at 13:04
0

sudo modprobe veth fixed this for me.

1
  • What is this command doing?
    – zingi
    Nov 29, 2022 at 13:07

You must log in to answer this question.

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