Skip to content

Instantly share code, notes, and snippets.

@hemanth22
Forked from murarisumit/docker_cheatsheet.md
Created September 11, 2019 15:02
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 hemanth22/341868df91e3b4d6dc42cf0425067c0e to your computer and use it in GitHub Desktop.
Save hemanth22/341868df91e3b4d6dc42cf0425067c0e 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