Docker Cli Commands Cheat Sheet



My Apache Kafka, CLI cheat sheet might be helpful for you! For every command, I also provide a practical working example you can execute in a running Kafka Docker container.

  1. Docker Command Line Cheat Sheet
Docker command line cheat sheet
  • Docker Kubernetes Service Cheat Sheet Docker Desktop Run Docker Kubernetes Service includes Compose on Kubernetes by default for both UCP clusters and Desktop.
  • Microsoft Azure CLI is necessary for every Azure cheat sheet. Azure command-line interface refers to the command-line tool used for the management of Azure resources. Moreover, it offers better learning and understanding of the use of commands. CLI is also a powerful tool for creating custom automation for using Azure resources.
  • This tutorial brings you a docker command cheat list in a printable A4 size and also in a pdf format for your quick reference. Please keep us posted if you need us to add more commands. Commands are categorized in 7 sections as listed below. Contents of Docker Cheat sheet. Starting and Stopping; 1.3.
Basic Docker Commands

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

Downloads image

-q less verbose

$ docker pull jenkins/jenkins:lts-jdk11

docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

Creates a new container

-d run a container in background and print container id
–name assign a name to the container
-p <local port>:<container port> publish container’s port to the host
-v <local file system>:<container file system> mount a volume

$ docker run -d –name jenkins -p 8085:8080 -v “/docker_volume/jenkins”:/var/jenkins_home jenkins/jenkins:lts-jdk11

docker images [OPTIONS] [REPOSITORY[:TAG]]

Lists all images, repositories, tags and their size

-a show all images (default hides intermediate images)

docker build [OPTIONS] PATH | URL | -

Build an image from the docker file, by default it looks for ‘Dockerfile’

$ docker build .

Cleanup

docker rmi [OPTIONS] IMAGE [IMAGE…]

Remove one or more images

-f force remove image

$ docker rmi -f 8b7c2b10838b 1a7a055a6252

docker rm [OPTIONS] CONTAINER [CONTAINER…]

Remove one or more containers

-f force remove running container

Container

Docker Command Line Cheat Sheet

docker container start [OPTIONS] CONTAINER [CONTAINER…]

Start one or more containers

-i interactive mode; attach container’s STDIN

$ docker container start jenkins

docker container stop [OPTIONS] CONTAINER [CONTAINER…]

Stop one or more containers

$ docker container stop jenkins

docker container ls [OPTIONS]

List containers

-a show all containers (default shows just running)
-q only display container id’s
-s display total file size

$ docker container ls

docker container logs [OPTIONS] CONTAINER

Display logs of the container

-f follow log output
–tail <number> number of lines to show from the end of the log

$ docker container logs –tail 5 jenkins

docker container exec [OPTIONS] CONTAINER COMMAND [ARG…]

Run a command in a running container

-d run command in the background
-i interactive mode, keep STDIN open
-t allocate a pseudo-TTY

$ docker container exec -it jenkins /bin/bash

docker container diff CONTAINER

List changed files and directories on the container

$ docker container diff jenkins

docker container stats [OPTIONS] [CONTAINER…]

Display live stream on container resource usage statistics

$ docker container stats jenkins

docker container inspect [OPTIONS] CONTAINER [CONTAINER…]

Display detailed information on one or more container’s

$ docker container inspect jenkins

docker container kill [OPTIONS] CONTAINER [CONTAINER…]

Kill one or more running container’s

$ docker container kill jenkins