Last active
August 4, 2019 03:07
-
-
Save suzuki-shunsuke/272a873c6e1775e6ff994c8d7c923a20 to your computer and use it in GitHub Desktop.
The one liner to create a ~/.docker/config.json for CI/CD. The environment variables USER_NAME, PASSWORD, and REGISTRY are parameters to login the Docker registry.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -v /var/run/docker.sock:/var/run/docker.sock -ti --rm -e USER_NAME=$USER_NAME -e PASSWORD=$PASSWORD docker:19.03.1 sh -c 'echo $PASSWORD | docker login $REGISTRY --username $USER_NAME --password-stdin > /dev/null 2> /tmp/error.txt && cat /root/.docker/config.json || (cat /tmp/error.txt >&2 && exit 1)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment