Skip to content

Instantly share code, notes, and snippets.

@zhangxu
Created March 25, 2016 02:13
Show Gist options
  • Save zhangxu/d2cd9b6c39cb627465ea to your computer and use it in GitHub Desktop.
Save zhangxu/d2cd9b6c39cb627465ea to your computer and use it in GitHub Desktop.
Docker Dangling Images
#!/bin/bash
#switch to docker daemon A
#build the base dummy the first pass
cat - << EOF | docker build -t ossa.docker.oraclecorp.com/dummy/helloworld:latest -
FROM busybox
RUN echo "world" > hello.txt
EOF
docker push ossa.docker.oraclecorp.com/dummy/helloworld:latest
#switch to docker daemon B
#build the child the first pass
cat - << EOF | docker build -t child:latest -
FROM ossa.docker.oraclecorp.com/dummy/helloworld:latest
CMD ["ls", "-lh"]
EOF
#Switch back to daemon A
#build the base dummy the second pass with some modifications
cat - << EOF | docker build -t ossa.docker.oraclecorp.com/dummy/helloworld:latest -
FROM busybox
RUN echo "world" > hello-again.txt
EOF
docker push ossa.docker.oraclecorp.com/dummy/helloworld:latest
#Switch back to B and build the child again
cat - << EOF | docker build --pull -t child:latest -
FROM ossa.docker.oraclecorp.com/dummy/helloworld:latest
CMD ["ls", "-lh"]
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment