Skip to content

Instantly share code, notes, and snippets.

@SteveBate
Last active November 26, 2023 19:55
Show Gist options
  • Save SteveBate/8278fd6c3251ff9e9933f48fdce58545 to your computer and use it in GitHub Desktop.
Save SteveBate/8278fd6c3251ff9e9933f48fdce58545 to your computer and use it in GitHub Desktop.
Docker

build a docker image from a Dockerfile using the files in the current (.) directory

  • docker image build -t stevebate/devrepo:tc-v1 .

list the docker images on disk

  • docker images

list of containers (instances)

  • docker ps
  • docker container ls -a (-a flag to see exited containers)

run a docker instance - parameter order is crucial and port mapping is host:container

  • docker run -d -p 81:5000 --name tcal stevebate/devrepo:tc-v1

stop/start containers

  • docker stop tcal (or image id)
  • docker start tcal (or image id)

remove images/containers

  • docker rm image id)
  • docker rmi image id

stop all running containers (not launched by docker compose)

  • docker stop $(docker container list -qa)

remove all exited containers

  • docker ps -a -q -f status=exited|xargs docker rm

remove dangling images

  • docker system prune

start multiple containers at the same time via a docker compose file

  • docker-compose --build up

gracefully shutdown all containers launched via docker compose

  • docker-compose down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment