Skip to content

Instantly share code, notes, and snippets.

@adifahmi
Created April 16, 2019 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adifahmi/35d8647ce9fea082f415fb36dc0442b9 to your computer and use it in GitHub Desktop.
Save adifahmi/35d8647ce9fea082f415fb36dc0442b9 to your computer and use it in GitHub Desktop.
Some docker commands
Build image from Dockerfile
docker build --pull --no-cache -t <IMAGE_NAME> .
Run image
docker run <IMAGE_NAME>
Stop container
docker stop <CONTAINER_ID>
List all container
docker container -a
(-a is optional to show all)
Inspect container (can be used to get network)
docker inspect <CONTAINER_ID>
Remove all dangling image
docker rmi $(docker images -f "dangling=true" -q)
Remove all exited container
docker rm $(docker ps -a -f status=exited -q)
Remove all images (can't remove image that has running container)
docker rmi $(docker images -a -q)
Remove single image
docker rm <IMAGE_ID>
List all images
docker images -a
Build Dockerfile and run it with docker-compose
docker-compose up
Rebuild docker compose
docker-compose up --build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment