Skip to content

Instantly share code, notes, and snippets.

@HenriqueMitsuo
Last active December 28, 2020 16:39
Show Gist options
  • Save HenriqueMitsuo/fe43df6b7ba5ba44bd1c79ba52795867 to your computer and use it in GitHub Desktop.
Save HenriqueMitsuo/fe43df6b7ba5ba44bd1c79ba52795867 to your computer and use it in GitHub Desktop.
Docker Reference

Docker Commands Reference

docker pull: docker pull [OPTIONS] NAME[:TAG|@DIGEST]

  • docker pull jturping/hollywood
    • Pull an image or a repository from a registry

docker inspect: docker inspect [OPTIONS] NAME|ID [NAME|ID...]

  • docker inspect node:12-stretch
    • Outputs metadata about the container

docker ps: docker ps [OPTIONS]

  • docker ps
    • list all running containers

docker run: docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

  • docker run ubuntu:bionic
    • runs the container
  • docker run -it ubuntu:bionic
    • runs the container and connects to it in bash with the -it flag
  • docker run -it --detach ubuntu:bionic
    • runs the container in background with --detach or -dit flag
  • docker run -it -detach --name my-container alpine:3.10
    • runs the container with a --name flag
  • docker run -it -detach --name my-container --rm alpine:3.10
    • --rm flag removes all the metadata when the container is killed

docker attach: docker attach [OPTIONS] CONTAINER

  • docker attach d226d5498cd4
    • connects to a container running in the background using the container id from docker ps or name

docker kill: docker kill [OPTIONS] CONTAINER [CONTAINER...]

  • docker kill d226d5498cd4
    • kill the running container using the container id from docker ps or name
  • docker kill $(docker ps -q)
    • kill all the running containers

docker rm: docker rm [OPTIONS] CONTAINER [CONTAINER...]

  • docker rm my-container
    • removes the metadata from a container using the container id from docker ps or name

docker pause: docker pause CONTAINER [CONTAINER...]

  • docker pause d226d5498cd4
    • Pause all processes within one or more containers using the container id from docker ps or name

docker unpause: docker unpause CONTAINER [CONTAINER...]

  • docker unpause d226d5498cd4
    • Unpause all processes within one or more containers using the container id from docker ps or name

Reference links

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