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 Gitlab CI).
To set this up, install the docker-credentials-gitlab_runner
script somewhere
in the Gitlab runner users path (it needs to be named docker-credential-gitlab_runner
),
then configure the Gitlab runner user's ~/.docker/config.json
file to use it:
{ "credsStore": "gitlab_runner" }
you also need to have the following environment variables set:
CI_REGISTRY - Your registry URL
CI_REGISTRY_USER - Your username
CI_REGISTRY_PASSWORD - Your password
which should already be set for the job if you are using Gitlab runner, see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
This is based on https://gist.github.com/jasonk/480d87b49e4c8caf51932f184ff764b2 from @jasonk
Thank you! This should be gitlab-runner default behavior.