Master Docker Basic Commands: Your Essential CLI Guide

Logan Jul 13, 2026

Welcome to the world of Docker! If you're here, you're probably eager to understand and start using Docker, a popular tool for automated deployment, scaling, and orchestration of applications using containerization. Docker allows you to package an application along with all its dependencies and run it consistently across various environments. Let's dive into the basic Docker commands to help you get started.

Docker Cheat Sheet 🐳 | Commands, Containers, Dockerfile & DevOps Basics
Docker Cheat Sheet 🐳 | Commands, Containers, Dockerfile & DevOps Basics

Before we start, ensure Docker is installed on your system. You can download it from the official Docker website. Once installed, you can verify it by running the command:

30 DOCKER COMMANDS EVERY DEVELOPER SHOULD KNOW
30 DOCKER COMMANDS EVERY DEVELOPER SHOULD KNOW

Docker Basics

Now that Docker is set up, let's explore some basic commands to interact with Docker.

the docker command chart is shown in red and purple colors, with text below it
the docker command chart is shown in red and purple colors, with text below it

Running Docker

To start Docker, use the following command in your terminal:

Basic Docker commands
Basic Docker commands

docker --version

This command will output the Docker version installed on your system, verifying that Docker is running.

Creating and Managing Docker Images

Docker images are the building blocks of Docker, functioning as a read-only template for creating containers. To manage Docker images, use these commands:

50 Most Used Docker Commands for DevOps & Cloud Engineers
50 Most Used Docker Commands for DevOps & Cloud Engineers
  • List all Docker images:
    docker images
  • Pull a Docker image from Docker Hub:
    docker pull [IMAGE_NAME]:[TAG]
  • Build a Docker image from a Dockerfile:
    docker build -t [IMAGE_NAME]:[TAG] .
  • Remove a Docker image:
    docker rmi [IMAGE_ID|IMAGE_NAME]:[TAG]

Working with Docker Containers

Docker containers are instances of Docker images, running as separate processes. They allow you to package, deploy, and run applications in isolated environments.

The Docker Cheat Sheet Developers Keep Coming Back To
The Docker Cheat Sheet Developers Keep Coming Back To

Creating and Managing Docker Containers

Use the following commands to manage Docker containers:

Essential Docker Commands
Essential Docker Commands
Important Commands for Docker
Important Commands for Docker
Simplify Your Container Management: 21 Docker Commands to Learn
Simplify Your Container Management: 21 Docker Commands to Learn
Docker Explained Simply Containers, Images, Commands & Why Every Developer Needs It
Docker Explained Simply Containers, Images, Commands & Why Every Developer Needs It
Akash Kumar on LinkedIn: Most Commonly Used Docker Commands CheatSheet  🐳 As Docker gains… | 17 comments
Akash Kumar on LinkedIn: Most Commonly Used Docker Commands CheatSheet 🐳 As Docker gains… | 17 comments
Coding Snow
Coding Snow
the docker commands poster is shown
the docker commands poster is shown
⌨️ Essential Docker Commands: A Quick Reference Guide 🚀
⌨️ Essential Docker Commands: A Quick Reference Guide 🚀
the docker chat sheet is shown in blue and black, with text on it
the docker chat sheet is shown in blue and black, with text on it
100 Docker Basic Commands with Examples
100 Docker Basic Commands with Examples
Docker cheat sheet
Docker cheat sheet
Docker Developers
Docker Developers
Docker Explained: Containers, Images & DevOps Simplified
Docker Explained: Containers, Images & DevOps Simplified
the docker commands mindmap is shown in this graphic above it's description
the docker commands mindmap is shown in this graphic above it's description
Top Docker Commands Every Developer Should Know
Top Docker Commands Every Developer Should Know
Essential Docker Compose Commands: A Quick Guide 🚀
Essential Docker Compose Commands: A Quick Guide 🚀
the docker cheat sheet is shown in blue
the docker cheat sheet is shown in blue
Docker
Docker
  • List all Docker containers:
    docker ps -a
  • Run a Docker container in the background:
    docker run -d [IMAGE_NAME]:[TAG]
  • Run a Docker container in the foreground:
    docker run [IMAGE_NAME]:[TAG]
  • Stop a Docker container:
    docker stop [CONTAINER_ID|CONTAINER_NAME]
  • Remove a Docker container:
    docker rm [CONTAINER_ID|CONTAINER_NAME]

Viewing and Accessing Docker Containers

To view and access running Docker containers, use these commands:

View the logs of a container:
docker logs [CONTAINER_ID|CONTAINER_NAME]

Execute a command in a running container:
docker exec [CONTAINER_ID|CONTAINER_NAME] [COMMAND]

Access the shell of a running container:
docker exec -it [CONTAINER_ID|CONTAINER_NAME] /bin/bash

Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications. It uses a YAML file to configure the services of your application. To get started, create a docker-compose.yml file in your project directory and define your services:

Example of a simple docker-compose.yml file:

```yaml version: '3' services: web: image: nginx:latest ports: - "80:80" db: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress ```

To run your application using Docker Compose, use the following commands:

  • Start and bring up services:
    docker-compose up
  • Stop and remove containers:
    docker-compose down

Now that you've explored the basic Docker commands, you're well on your way to harnessing the power of containerization. Happy Docker-ing!