Created
June 23, 2017 10:45
-
-
Save stampycode/74cf50dbd48b3857906ada6ed3385676 to your computer and use it in GitHub Desktop.
Connect to Docker Registry and Fetch an Image without hard-coding credentials
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
#!/bin/bash | |
if [[ ! -f bin/docker-credential-registrycreds ]] ; then | |
[[ ! -d bin ]] && mkdir bin | |
cat > bin/docker-credential-registrycreds <<FFF | |
cat <<JSON | |
{ | |
"ServerURL": "https://registry.local/v1", | |
"Username": "${DOCKER_USER}", | |
"Secret": "${DOCKER_PASS}" | |
} | |
JSON | |
FFF | |
chmod u+x bin/docker-credential-registrycreds | |
fi | |
if [[ ! -f .docker/config ]] ; then | |
[[ ! -d .docker ]] && mkdir .docker | |
cat > .docker/config.json <<FFF | |
{ | |
"credsStore": "registrycreds" | |
} | |
FFF | |
fi | |
read -p "docker registry username: " DOCKER_USER | |
read -p "docker registry password: " -s DOCKER_PASS | |
export DOCKER_USER | |
export DOCKER_PASS | |
export PATH=$PATH:/root/bin/ | |
docker pull registry.local/your/path/to/repo:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment