Nonzero [error] code on gpg: keyserver receive failed: Cannot assign requested address Nonzero [error] code on gpg: keyserver receive failed: Cannot assign requested address docker docker

Nonzero [error] code on gpg: keyserver receive failed: Cannot assign requested address


Following the recommendation from Laurent Sittler, the solution was on adding options to the gpg servers.

Find this line in the Dockerfile:

&& gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \

and replace it with this block:

&& ( \  gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \    || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPG_KEY" \    || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPG_KEY" \) \


UPDATE: Any change in the code has no effect. You need to run your code again until it works (or you add more download locations to go through in an if-statement so that the chance is less that you do not catch a download); see the other answer of this thread.

I just leave the following old part here as a proof that any placebo code changes did not help me, it was random and it strangely appeared at every first run, while at the second, it usually worked.


Run

sudo apt-get update

before you run

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0F164EEB

And if you have an "echo" line before that, run another sudo apt-get update even before that:

RUN apt-get updateRUN sh -c 'echo "..." > /etc/...'RUN apt-get updateRUN apt-key adv ...

By this, I got rid of the similar error "Cannot assign requested address":

Executing: /tmp/apt-key-gpghome.Up2U8vHXpt/gpg.1.sh --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6gpg: keyserver receive failed: Cannot assign requested addressERROR: Service 'listener' failed to build: The command '/bin/sh -c apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6' returned a non-zero code: 2

Most likely: server is just busy, try again

This could be a placebo, though, since this answer to the same error, but in another context says that this can appear when the address is just busy. Which would mean: if you have this error, just try again, and sudo apt-get update might not change anything, then. That sounds most likely.