Skip to content

Instantly share code, notes, and snippets.

@Infra-Red
Last active April 13, 2018 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Infra-Red/7e4c5c2cb5e96760fc6d45abdadfff52 to your computer and use it in GitHub Desktop.
Save Infra-Red/7e4c5c2cb5e96760fc6d45abdadfff52 to your computer and use it in GitHub Desktop.
Push private docker hub images to Cloud Foundry
#!/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
@CovisintRND
Copy link

CovisintRND commented Apr 13, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment