I am getting this message on building a Debian:stretch-slim Docker image with Python 3.7.7:
gpg: keyserver receive failed: Cannot assign requested address
The command '/bin/sh -c set -ex [...]'
[...] returned a non-zero code: 2
I think it’s a GPG or a networking issue.
Any tips? Your assistance is highly appreciated.
2
Answers
Following the recommendation from Laurent Sittler, the solution was on adding options to the gpg servers.
Find this line in the Dockerfile:
and replace it with this block:
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
before you run
And if you have an "echo" line before that, run another
sudo apt-get update
even before that:By this, I got rid of the similar error "Cannot assign requested address":
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.