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 update
RUN sh -c 'echo "..." > /etc/...'
RUN apt-get update
RUN 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 C1CF6E31E6
gpg: keyserver receive failed: Cannot assign requested address
ERROR: 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.