Skip to content

Instantly share code, notes, and snippets.

@gdumitrescu
Created March 8, 2016 19:41
Show Gist options
  • Save gdumitrescu/0ddaf2af111254045775 to your computer and use it in GitHub Desktop.
Save gdumitrescu/0ddaf2af111254045775 to your computer and use it in GitHub Desktop.
publish docker image to dockerhub with a provided name
#!/usr/bin/env bash
# get docker image name from input
docker_image=$1
# remove local docker image
docker rmi $docker_image
# build new docker image
docker build .
# get the ID of new dangling image
docker_image_id=$(docker images -q --filter dangling=true)
# tag docker image
docker tag "$docker_image_id" "$docker_image"
# push docker image
docker push $docker_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment