docker: Error response from daemon: failed to create endpoint - failed to add host

21,301

Solution 1

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

Solution 2

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.

Solution 3

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

Share:
21,301

Related videos on Youtube

Machiavelli
Author by

Machiavelli

Updated on September 18, 2022

Comments

  • Machiavelli
    Machiavelli 8 months

    Everything was working, but suddenly I'm getting an error every time I run a Docker container.

    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 should I do?

    • Mark Allen
      Mark Allen over 1 year
      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
    • Jon Thomason
      Jon Thomason over 1 year
      This deserves a full answer (not a comment), and answered my question. Thank you!
  • Machiavelli
    Machiavelli about 6 years
    Yea, I forgot to update this but I restarted and it worked like a charm. Not sure why this happens.
  • Kusalananda
    Kusalananda about 6 years
    @Machiavelli If this answer solves your issue, please consider accepting the answer.
  • Patrick Motard
    Patrick Motard about 5 years
    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.
  • Neel Patel almost 5 years
    This is not a solution, but a workaround.
  • domenukk
    domenukk about 4 years
    Things like this make me want to leave computers behind and look into woodcutting
  • Nathan
    Nathan over 3 years
    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.
  • AdminBee
    AdminBee over 1 year
    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.