Last active
September 19, 2017 09:14
-
-
Save dergachev/d3528271f4e9fbc0ba8d to your computer and use it in GitHub Desktop.
Useful Makefile snippets for docker usage
This file contains hidden or 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
name=coursecal-d7 | |
port=$(shell docker inspect -format='{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' $(name)) | |
# launches a debug shell into the latest intermediate docker image | |
debug_latest: | |
docker run -t -i `docker images -q | head -n 1` /bin/bash | |
# DESTROYS all containers (!!) and all images without a tag | |
# NB: | |
# - running containers are protected by 'docker rm' | |
# - ancestors of tagged images are protected by 'docker rmi' | |
clean: | |
-docker ps -a -q | xargs docker rm | |
-docker images -a | grep "^<none>" | awk '{print $$3}' | xargs docker rmi | |
# SSH into the running container | |
ssh: | |
ssh localhost -l root -p $(port) -o ForwardAgent=yes -o NoHostAuthenticationForLocalhost=yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment