docker: Error response from daemon: failed to create endpoint - failed to add host
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.
Related videos on Youtube

Machiavelli
Updated on September 18, 2022Comments
-
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 over 1 yearIf 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 over 1 yearThis deserves a full answer (not a comment), and answered my question. Thank you!
-
-
Machiavelli about 6 yearsYea, I forgot to update this but I restarted and it worked like a charm. Not sure why this happens.
-
Kusalananda about 6 years@Machiavelli If this answer solves your issue, please consider accepting the answer.
-
Patrick Motard about 5 yearsFor 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 yearsThis is not a solution, but a workaround.
-
domenukk about 4 yearsThings like this make me want to leave computers behind and look into woodcutting
-
Nathan over 3 yearsIn 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 over 1 yearWelcome 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.