Skip to content

Instantly share code, notes, and snippets.

@ali-farhad
Last active May 8, 2022 15:07
Show Gist options
  • Save ali-farhad/fad37b1021606e665ec1c9297543db68 to your computer and use it in GitHub Desktop.
Save ali-farhad/fad37b1021606e665ec1c9297543db68 to your computer and use it in GitHub Desktop.
MY DOCKER BABIES
# 1. see all docker images
docker images
# build image from docker file if the docker file is in CWD.
docker build -t myimage .
# build image from docker file with tag
docker build -t myimage:V1 .
# run image with name/id
docker run myapp
# give container name before running
docker run --name myapp_c myapp
# run container but then have it deleted after we exit
docker run --name myapp_temp --rm <image_name>
# get all running processes / containers of docker
docker ps
# get all processes / container (even if they are stopped)
docker ps -a
# stop process / container
docker stop myapp_c
# run docker container from image with port exposed in detached (non blocking) way
docker run --name myapp_d -p 80:4000 -d myapp
# restart a container
docker start myapp_d
# diff b/w run and start
==> run creates a new container from image
==> start restarts an already made container (we don't need to specify ports and names because that is already done when Running the container)
# delete an image not being used
docker image rm <img name>
# delete image even if it is being used
docker image rm <img name> -f
# delete existing container
docker container rm <container name>
# go nuclear - delete all images / containers
docker system prune -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment