Created
November 13, 2014 06:22
-
-
Save gigablah/8e7d7a5fc5294c64587a to your computer and use it in GitHub Desktop.
Flatten docker image
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 | |
# See: https://github.com/deis/deis/pull/1825 | |
IMAGE=$1 | |
NEW_IMAGE=$HOST:$PORT/$2:$3 | |
NOW=$(date +"%m%d%Y%H%M%S") | |
if [ "$#" -ne 3 ]; then | |
echo "Illegal number of parameters" | |
exit 1 | |
fi | |
echo "Exporting running image $IMAGE" | |
docker export $IMAGE | docker import - $NOW | |
echo "Creating tag for $NOW as $NEW_IMAGE" | |
docker tag $NOW $NEW_IMAGE | |
echo "Pushing new image to local registry" | |
docker push $NEW_IMAGE | |
echo "Removing temporal image $NOW" | |
docker rmi -f $NOW |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment