Categories: Cheat Sheet

The Docker Cheat Sheet

Basic Docker CLIs

Here’s the list of the basic Docker commands that works on both Docker Desktop as well as Docker Engine:

Container Management CLIs

Here’s the list of the Docker commands that manages Docker images and containers flawlessly:

Inspecting The Container

Here’s the list of the basic Docker commands that helps you inspect the containers seamlessly:

Interacting with Container

Do you want to know how to access the containers? Check out these fundamental commands:

Image Management Commands

Here’s the list of Docker commands that helps you manage the Docker Images:

Image Transfer Commands

Here’s the list of Docker image transfer commands:

Builder Main Commands

Want to know how to build Docker Image? Do check out the list of Image Build Commands:

The Docker CLI

Manage images

docker build

docker build [options] .
  -t "app/container_name"    # name

Create an image from a Dockerfile.

docker run

docker run [options] IMAGE
  # see `docker create` for options

Run a command in an image.

Manage containers

docker create

docker create [options] IMAGE
  -a, --attach               # attach stdout/err
  -i, --interactive          # attach stdin (interactive)
  -t, --tty                  # pseudo-tty
      --name NAME            # name your image
  -p, --publish 5000:5000    # port map
      --expose 5432          # expose a port to linked containers
  -P, --publish-all          # publish all ports
      --link container:alias # linking
  -v, --volume `pwd`:/app    # mount (absolute paths needed)
  -e, --env NAME=hello       # env vars

Example

$ docker create --name app_redis_1 \
  --expose 6379 \
  redis:3.0.2

Create a container from an image.

docker exec

docker exec [options] CONTAINER COMMAND
  -d, --detach        # run in background
  -i, --interactive   # stdin
  -t, --tty           # interactive

Example

$ docker exec app_web_1 tail logs/development.log
$ docker exec -t -i app_web_1 rails c

Run commands in a container.

docker start

docker start [options] CONTAINER
  -a, --attach        # attach stdout/err
  -i, --interactive   # attach stdin

docker stop [options] CONTAINER

Start/stop a container.

docker ps

$ docker ps
$ docker ps -a
$ docker kill $ID

Manage containers using ps/kill.

Images

docker images

$ docker images
  REPOSITORY   TAG        ID
  ubuntu       12.10      b750fe78269d
  me/myapp     latest     7b2431a8d968
$ docker images -a   # also show intermediate

Manages images.

docker rmi

docker rmi b750fe78269d

Deletes images.

reference: here

ferisetyawanmyid

🚀 Certified Linux System Administrator | DevOps | Server Optimization | Cybersecurity | DRC Solutions

Share
Published by
ferisetyawanmyid

Recent Posts

How to Install CyberPanel on Ubuntu 24.04 LTS (Step-by-Step Guide)

CyberPanel is a modern web hosting control panel powered by OpenLiteSpeed, designed for high performance,…

8 months ago

Welcome to My Personal Blog

🚀 Certified Linux System Administrator | DevOps | Server Optimization | Cybersecurity | DRC Solutions…

9 months ago

10 Essential Linux Commands Every SysAdmin Should Know

As a Linux System Administrator, mastering the command line is key to efficiently managing servers,…

10 months ago

🚀 How to Install WireGuard with Docker on Ubuntu 24.04 (wg-easy Dashboard)

Introduction WireGuard is a fast, lightweight, and modern VPN protocol designed for simplicity and performance.If…

11 months ago

How To Install Certbot on Ubuntu 24.04: Set Up Let’s Encrypt for Apache and Nginx

Securing your website with HTTPS is essential for privacy, SEO ranking, and user trust. Let’s…

11 months ago

Best SSH Clients for Linux: Top Tools for Secure Remote Connections

If you manage Linux servers regularly, you know how important SSH (Secure Shell) is. Whether…

11 months ago

This website uses cookies.