elcortegano
elcortegano

Reputation: 2684

Docker build error: failed to add the host

I'm facing an unexpected error when running docker build, and I say unexpected because I haven't changed my Dockerfile for a while, and it had worked fine for the last time two weeks ago, but now I'm getting the following error:

failed to create endpoint optimistic_spence on network bridge: failed to add the host (veth9fc3a03) <=> sandbox (veth15abfd6) pair interfaces: operation not supported

In case it is of any help:

Dockerfile looks like:

FROM alpine:3.4

LABEL version="current version"
LABEL description="A nice description."
LABEL maintainer="[email protected]"

RUN apk update && apk add \
    gcc \
    g++ \
    make \
    git \
    && git clone https://gitlab.com/user/repo.git \
    && cd repo \
    && make \
    && cp program /bin \
    && rm -r /repo \
    && apk del g++ make git

WORKDIR /tmp

ENTRYPOINT ["program"]

Does anybody understand what is going on? Thank you!

EDIT When combined with the --network option, the error changes a little, but it won't fix the problem. For example, --network=host gives the following:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.4/main: temporary error (try again later)

WARNING: Ignoring APKINDEX.167438ca.tar.gz: No such file or directory

fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.4/community: temporary error (try again later)

WARNING: Ignoring APKINDEX.a2e6dac0.tar.gz: No such file or directory 2 errors; 11 distinct packages available

The command '/bin/sh -c apk update && apk add gcc g++ make git && git clone https://gitlab.com/user/repo.git && cd repo && make && cp program /bin && rm -r /repo && apk del g++ make git' returned a non-zero code: 2

Upvotes: 11

Views: 19420

Answers (4)

David van rijn
David van rijn

Reputation: 2220

Just to add to the possible causes. For me (and probably @testix) it was because i did a system upgrade (archlinux), so my kernel modules got upgraded, but i was still running the old kernel, so modules could not be loaded. You can try do modprobe a random module:

modprobe vcan
modprobe: FATAL: Module vcan not found in directory /lib/modules/6.2.7-arch1-1

This means that you have to reboot, (or use --network if you can get away with it).

Upvotes: 3

Testix
Testix

Reputation: 313

Had the same error and systemctl restart docker nor pruning og images & system did not do it for me, I ended up rebooting my computer which seems o have resolved the issue.

Upvotes: 19

elcortegano
elcortegano

Reputation: 2684

Two times I have faced this issue and the way to fix it has always been the same. I'm posting in case it can be of any help for somebody:

  • First, make sure that the DNS server is properly set up (eg. setting DNS to 1.1.1.1).
  • Second, restarting the docker daemon.

For those using systemd in Linux, systemctl restart did not the job for me. I had to stop and start docker to make it work. After that, I could login and pull images again.

Upvotes: 1

Alejandro Galera
Alejandro Galera

Reputation: 3691

It looks that something wrong happened with any docker network bridge and it doesn't let you to create the same because is "zombie".

Try with following steps:

  1. docker network prune, and if it doesn't work, try with:
  2. docker system prune <-- Careful, this also will purge your named volumes contents, i.e, volumes that are not assigned to a container. So, if you have volumes assigned to a container, you should have to re-build/create containers.
  3. /etc/init.d/docker restart

Show me what happens and let's see, actually I need more info about your problem if it doesn't solve it to you.

Upvotes: 6

Related Questions