I’m running bitcoind 0.20.1 inside a Docker container and would like to access its RPC interface from another container.
Docker has a way to manage secrets like the RPC authentication cookie and safely pass them between containers. Effectively, it mounts the secret as a file like /run/secrets/rpc_cookie
. I’d like bitcoind to use the cookie from that file.
I tried -rpccookiefile=/run/secrets/rpc_cookie
, but bitcoind tries to write to that file and fails. Of course, it’s read-only.
Alternatives: Docker doesn’t support to insert secrets (which can be any data, including binary) into configuration files or to pass it as a command line argument (which would leak the cookie anyway, I guess).
Proposal: I propose adding a mode in which bitcoind reads the authentication cookie from file, rather than trying to create a new one. That mode could be auto-enabled if the specified cookie file exists on startup and is read-only.
Side note: Because of at least one consumer of the RPC API (electrs) only supports reading cookies from file (both command like arguments and environment variables are deemed insecure), I will now have to define the same secret at two places – which I think has a higher risk to leak the secret.