This is a very basic Docker credential helper that uses environment variables to authenticate to Docker. It's not as secure as the other credential helpers that Docker provides, but it can be very helpful in some circumstances (such as when using it with Jenkins).
To set this up, install the docker-credentials-env
script somewhere
in the Jenkins users path (it needs to be named docker-credential-env
),
then configure the Jenkins user's ~/.docker/config.json
file to use it:
{ "credsStore": "env" }
To use it, you need to have the following environment variables set:
DOCKER_REGISTRY - Your registry URL
DOCKER_CREDS_USR - Your username
DOCKER_CREDS_PSW - Your password
If you are using Jenkins Declarative Pipeline, you can do this in the environment section of your Jenkinsfile (see the example Jenkinsfile).