No entropy
Docker does not provide virtual devices /dev/[u]random . If you don’t have enough entropy in the container, you don’t have enough entropy on the host.
Check the contents of /proc/sys/kernel/random/entropy_avail , they should be almost the same on the host and the Docker container (if the number is slightly different, it just changes very often, otherwise check back several times).
Possible reasons:
- Running the docker host in a virtual machine, for example, because of
boot2docker or a self-built virtual machine. Just make sure you have more entropy inside your virtual machine, havegd is a very simple solution for a developer's machine, but may not be suitable for production. - Another container / application uses all entropy. Implement which one to interrupt / terminate or create more entropy.
- Usually you do not have enough entropy. Do some work (mouse / keyboard movement, (hard) I / O drive).
External key pair creation
In any case, it would be wiser to create a key on a real machine and only move the (closed) subsection to the server. Thus, you can exchange the unit from time to time (and if it is compromised). Read What is GnuPG Shared Key Configuration for General Purpose? to familiarize yourself with the various things to consider when setting up OpenPGP keys.
When creating a Docker image, use COPY to get the file in the machine, and then gpg --import in the Docker file. Subsequently, it is available exactly as if you created it inside a container using gpg --gen-key .
source share