Skip to content

Instantly share code, notes, and snippets.

@dergachev
Last active September 19, 2017 09:14
Show Gist options
  • Save dergachev/d3528271f4e9fbc0ba8d to your computer and use it in GitHub Desktop.
Save dergachev/d3528271f4e9fbc0ba8d to your computer and use it in GitHub Desktop.
Useful Makefile snippets for docker usage
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