Skip to content

Instantly share code, notes, and snippets.

@bil0u
Last active June 11, 2019 15:17
Show Gist options
  • Save bil0u/8cae9a9fdb70d7e100c84a12530af516 to your computer and use it in GitHub Desktop.
Save bil0u/8cae9a9fdb70d7e100c84a12530af516 to your computer and use it in GitHub Desktop.
[Docker commands] Some useful docker commands #cheatsheet #docker
List Docker CLI commands

docker
docker <subcommand> --help

Display Docker version and info

docker version
docker info

Execute Docker image

docker run hello-world

List Docker images

docker image ls

List Docker containers (running, all, all in quiet mode)

docker container ls
docker container ls --all
docker container ls -aq

Build image from a dockerfile

docker build -t <tag_name> <path/to/dockerfile>

Run a docker container in background (remove -d for foreground)
  • -i : Keeps stdin open
  • -t : Allocates a tty
  • -d : Run the container in background
  • -p : Ports binding

docker run -itd -p <external_port>:<container_port> <tag_name>

Delete a container (stop it if running, then deletes it)

docker container rm -f <container_name>

Clean images
  • --all : Remove all unused images

docker system prune --all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment