Skip to content

Instantly share code, notes, and snippets.

@debdutgoswami
Created December 23, 2020 13:49
Show Gist options
  • Save debdutgoswami/86589fbd60cef00c893f21e2e3fc8e84 to your computer and use it in GitHub Desktop.
Save debdutgoswami/86589fbd60cef00c893f21e2e3fc8e84 to your computer and use it in GitHub Desktop.
One Place for all commonly used docker commands
# build an image
docker build .
# build docker image with a tag (recommended)
docker build -t <tag> .
# run an image
docker run <image/tag>
# run an image in background
docker run -d <image/tag>
# run with port exposed
docker run -i -p 8080:8080 <image/tag>
# run with port exposed and running in background
docker run -i -p 8080:8080 -d <image/tag>
# docker images
docker images -a
# stop running containers
docker stop <image/tag>
# remove images
docker rmi <image/tag>
# remove all images
docker rmi $(docker images -a -q)
# remove all stoped containers
docker container prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment