Skip to content

Instantly share code, notes, and snippets.

@maryshirl
Created June 27, 2018 02:34
Show Gist options
  • Save maryshirl/1acd740634393671ffdfaf267b9c6284 to your computer and use it in GitHub Desktop.
Save maryshirl/1acd740634393671ffdfaf267b9c6284 to your computer and use it in GitHub Desktop.
Docker cheat sheet
NOTES:
- <image-name> can be specified with tag at the end after ':'. Otherwise, it will fetch the 'latest' tag
- First line is the syntax, second line is the example command
Docker commands
ELASTIC CONTAINER REGISTRY (ECR) - Similar to DockerHub
List:
aws ecr describe-repositories
Create:
aws ecr create-repository --repository-name <repository-name>
aws ecr create-repository --repository-name carelever/invoice
Login:
(copy paste the output of the command below)
aws ecr get-login --no-include-email
IMAGES
List:
docker images
Show:
docker images --filter reference=<image-name>
Remove:
docker rmi <image-name || image-id>
Tag:
docker tag <image-name> <repository-uri>
docker tag carelever/invoice:1.0 459336845914.dkr.ecr.ap-southeast-2.amazonaws.com/carelever/invoice
Push:
docker push <repository-uri>
docker push 459336845914.dkr.ecr.ap-southeast-2.amazonaws.com/carelever/invoice
CONTAINERS
List:
docker ps -a
Remove:
docker rm <container-id || container-name>
Run:
docker run -it --name CUSTOM_NAME -p 3000:3000 <image-name>
docker run -it --name carelever/invoice -p 3000:3000 carelever/invoice:1.0
Build
docker build -t <image-name>
docker build -t carelever/invoice:1.0 .
Create From Existing Image
docker create --volumes-from <container-name> --name <container-name> <image-name>
Start
docker start <container-name>
Stop
docker stop <container-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment