Skip to content

Instantly share code, notes, and snippets.

@jbelmont
Last active September 25, 2019 19:37
Show Gist options
  • Save jbelmont/7ce06f065c8ddb8fba4332c0e57c8ae6 to your computer and use it in GitHub Desktop.
Save jbelmont/7ce06f065c8ddb8fba4332c0e57c8ae6 to your computer and use it in GitHub Desktop.
A list of command docker commands and scenarios.

Docker Commands cheat sheet list

Listing Images that you have in your local machine

$ docker images
REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
sourcegraph/server               3.8.0               504e86fa7376        6 days ago          833MB
nosql-workshop_mongo-router      latest              809631f8d908        11 days ago         394MB
alpine                           3                   961769676411        5 weeks ago         5.58MB
nosql-workshop_mongo-rs2-setup   latest              a42207d9c77c        4 months ago        394MB
setup-rs                         latest              4fa22614e4b0        4 months ago        394MB
mongo                            latest              5976dac61f4f        4 months ago        411MB
hashicorp/packer                 1.4.1               c312ba0fcdb8        4 months ago        217MB
golang                           1.11-alpine         6655e91e076d        6 months ago        311MB
python                           2.7.15              0313c3892dbc        7 months ago        912MB
jbelmont/mongo-vim               4.0.5               829ad727214b        7 months ago        472MB
api-workshop_web                 latest              33bea3b2ac28        8 months ago        240MB
api-workshop_apid                latest              98d61b584b1c        8 months ago        766MB
mongo                            4.0.5               4a3b93a299a7        8 months ago        394MB
nginx                            1.15-alpine         315798907716        9 months ago        17.8MB
swaggerapi/swagger-ui            latest              89e201331c4d        9 months ago        52.3MB
golang                           1.11.3-alpine       c283ac5a8f78        9 months ago        310MB
swaggerapi/swagger-editor        latest              8c752041891a        10 months ago       25.1MB
ubuntu                           latest              ea4c82dcd15a        11 months ago       85.8MB
docker/kube-compose-api-server   v0.4.12             0f92c77fa676        12 months ago       41.2MB
playground                       latest              88f6134f711e        12 months ago       8.91MB
playground_playground            latest              c5c48d6b5105        12 months ago       8.91MB
localstack/localstack            latest              c3a276e6a9e9        14 months ago       761MB
print-average                    latest              aa0b2712a203        15 months ago       378MB
jbelmont/print-average           1.0                 aa0b2712a203        15 months ago       378MB
docker/kube-compose-controller   v0.3.9              16260a912a7b        15 months ago       29.9MB
jenkinsci/blueocean              latest              5b3929ff788f        15 months ago       438MB
golang                           1.10-alpine         05fe62871090        16 months ago       376MB
mongo                            3.4                 9ad59b0c0624        18 months ago       360MB
mongo                            3.4.13              f48f036a935c        18 months ago       360MB
mongo                            3.2                 4ece83276ddb        18 months ago       300MB
mongo                            3.6.2               e6614928d693        19 months ago       366MB
alpine                           latest              3fd9065eaf02        20 months ago       4.15MB
redis                            3.2-alpine          f60c2c2ed490        22 months ago       19.8MB
busybox                          latest              6ad733544a63        23 months ago       1.13MB
redis                            3.2.9               3459037fcc3a        2 years ago         98.9MB
mongo                            3.4.5               71c101e16e61        2 years ago         358MB
mongo                            3.2.14              c370e8ecad13        2 years ago         299MB
redis                            3.2.4-alpine        906fffc0e2f4        2 years ago         20.4MB

Print docker version info

$ docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:26:49 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:32:21 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Show inforomation such as the number of containers, networks, etc.

$ docker info
Client:
 Debug Mode: false

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 105
 Server Version: 19.03.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.9.184-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 3.855GiB
 Name: docker-desktop
 ID: FIEX:UYPL:54AO:G66R:USM2:VTBA:OCKQ:BUQZ:LIGW:NHYL:JF6A:DFZU
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 31
  Goroutines: 47
  System Time: 2019-09-25T19:18:03.7319547Z
  EventsListeners: 2
 HTTP Proxy: gateway.docker.internal:3128
 HTTPS Proxy: gateway.docker.internal:3129
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

Show Docker help menu and commands

docker help

Usage:	docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/Users/jean-marcelbelmont/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set
                           with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/Users/jean-marcelbelmont/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/Users/jean-marcelbelmont/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/Users/jean-marcelbelmont/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  checkpoint  Manage checkpoints
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  deploy      Deploy a new stack or update an existing stack
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

Notice that there is management commands and commands, read the fine manual (RTFM) for guidance on what each command does and the flage or subcommands available for each of them

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