Skip to content

Instantly share code, notes, and snippets.

@byronmansfield
Last active February 27, 2016 18:11
Show Gist options
  • Save byronmansfield/25cf0f353a0a9e5260f5 to your computer and use it in GitHub Desktop.
Save byronmansfield/25cf0f353a0a9e5260f5 to your computer and use it in GitHub Desktop.
docker-cheatsheet
######################
# Docker Cheat Sheet #
######################
docker build -t <username>/<repo-name> . | builds an image
docker run -p 80:80 --name <somename> <username>/<repo> | runs a container from this image
docker ps -a | shows all contains even stopped
docker rm <name> | removes container
docker rmi <id> | removes image
docker inspect <container-id> | grep IPAddress | cut -d '"' -f 4 | gives ip address
docker inspect -f '{{.NetworkSettings.IPAddress}}' <app-name> | also gives ip address
docker rmi $(docker images | grep "^<none>" | awk '{print $3}') | removes all untagged docker images
docker rm $(docker ps -a -q) | removes all stopped containers
docker push <hub-user>/<repo-name>:<tag> | pushes image to registrery
docker exec -it <container-name> /bin/bash | start interactive terminal from container
#################
# Typical steps #
#################
- Make Dockerfile
- Build docker image or pull an built image
```
docker build
```
- Run container from that image
```
docker run
```
- Publish image
```
docker push
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment