Skip to content

Instantly share code, notes, and snippets.

@birchestx
Last active October 15, 2019 00:32
Show Gist options
  • Save birchestx/b078f921be10a8e0a939 to your computer and use it in GitHub Desktop.
Save birchestx/b078f921be10a8e0a939 to your computer and use it in GitHub Desktop.
Docker cheat commands
#Build new Image (uses dockerfile in cwd)
docker build -t <your-desired-image-name> .
#Run Docker Container
docker run <image-name>
#Stop Docker Container (if you have used --name you can then stop with actual alias name)
docker stop <image-id>
#Show running Docker Images
docker ps
#Run Container and ssh in
docker run -ti <image-name> /bin/bash
#ssh into existing container
docker exec -it <image-id> bash
#Run Container with specific alias name (useful for linking containers)
docker run -d -P --name <image-alias> <image-name>
#Get Docker Machine IP (needed if you want to access container e.g. tomcat)
docker-machine ip default
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images (be wary of using this one)
docker rmi -f $(docker images -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment