Last active
April 13, 2018 16:30
-
-
Save Infra-Red/7e4c5c2cb5e96760fc6d45abdadfff52 to your computer and use it in GitHub Desktop.
Push private docker hub images to Cloud Foundry
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 [ -z $3 ]; then | |
echo "Usage: $0 <app> <image> <start command>" | |
exit 1 | |
fi | |
# Dockerhub details | |
echo "Login with your Docker ID." | |
echo -n "Username: " | |
read USER | |
echo -n "Email: " | |
read MAIL | |
echo -n "Password: " | |
read -s PASS | |
# CF details | |
DOMAIN=`cf api | awk '{print $3}' | awk -F/ '{print $3}' | sed "s/^api.//"` | |
SPACE=`cf target | grep Space | awk '{print $2}'` | |
SPACE_GUID=`cf space $SPACE --guid` | |
DATA="{ | |
\"name\": \"$1\", | |
\"memory\": 1024, | |
\"instances\": 1, | |
\"disk_quota\": 1024, | |
\"space_guid\": \"$SPACE_GUID\", | |
\"docker_image\": \"$2\", | |
\"docker_credentials_json\" : { | |
\"docker_user\" : \"$USER\", | |
\"docker_password\" : \"$PASS\", | |
\"docker_email\" : \"$MAIL\" | |
}, | |
\"command\": \"$3\", | |
\"diego\": true | |
}" | |
cf curl /v2/apps -X POST -d "$DATA" | |
cf map-route $1 $DOMAIN -n $1 | |
cf set-env $1 DIEGO_DOCKER_CACHE true | |
cf start $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This results in:
builder exited with error: failed to fetch metadata from [covisintrnd/test-private-image] with tag [latest] and insecure registries [] due to unauthorized: authentication required
Any idea why?