Skip to content

Instantly share code, notes, and snippets.

@murarisumit
Last active December 30, 2022 00:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save murarisumit/a7eec953032bcc6a56e191bb58add790 to your computer and use it in GitHub Desktop.
Save murarisumit/a7eec953032bcc6a56e191bb58add790 to your computer and use it in GitHub Desktop.
docker cheatsheet #docker #cheatsheet

Docker cheatsheet, usually has one-lines to delete containers.

  • Create a image from docker file: docker build -t image-name .
  • Run a container: docker run -it --name container-name image-name:latest
  • Run docker in backgroud: docker run --name container-name --hostname container-hostname -t -d container-name:latest
  • Connect to container: docker exec -it container_name bash
  • Remove all Exited containers: sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
  • Remove all dangling images: docker rmi $(docker images -f 'dangling=true' -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment