Set container registry auth key via command line/env variable I'm trying to set up Jenkins CI pipeline which will be used to build docker images. I have my auth key stored in Jenkins credentials and I want it to be loaded on start in placed in some environment variable (already done).

Is it possible that Docker will read that environment variable and use the key for authenticating to my container registry?
Or maybe I can pass it somehow via command line?

I've tried searching for that in the docs, but only thing I found is that I can specify that values in config.json and specify the location of that. This is not the best option IMO.

Any ideas? Thanks in advance.
You mentioned that the auth key is stored in Jenkins credentials and are available as environment variables, if so, then your half task is already done; what you can probably do from here is, use those environment variables to perform docker login (assuming USERNAME and PASSWORD are the Jenkins credentials variable), use the below command to login

docker login your.docker-registry.com -u $USERNAME -p $PASSWORD


This assumes, that your registry has SSL enabled, if so, don't forget to place the registry certificates under the below name on your Jenkin host

/etc/docker/certs.d/your.docker-registry/ca.crt


Post this, you would be able to push image to the registry