Skip to main content

Docker Commands

These docker commands don’t fit neatly into any category but are essential on their own. They help you get more out of docker.

docker → The base command for the Docker CLI

docker version → Show the Docker version information

docker init → Creates Docker-related starter files for your project

docker search → Search Docker Hub for images

docker login → Authenticate to a registry

docker logout → Log out from a registry

docker inspect → Return low-level information on Docker objects

docker debug → Get a shell into any container or image.


Docker

docker  →  The base command for the Docker CLI
Usage:  docker [OPTIONS] COMMAND

Description:

Docker commands may need sudo. To skip that extra step, an admin can create a docker group and add users to it. Then you can run Docker directly - no sudo required. 🚀

 sudo groupadd docker
 sudo usermod -aG docker $USER
 newgrp docker

Docker Version

docker version  →  Show the docker version information
Usage : docker version [OPTIONS]

Description:

  • Prints the version numbers of all Docker components.
  • docker version → shows versions of Docker components.
  • docker -v, --version → shows the version of the Docker CLI itself.
  • Use --format to customize the output.

Docker Help

docker COMMAND --help → More information for the command

Description:

This command shows a list of available Docker commands and options. It’s like Docker’s built‑in guidebook for helping you quickly understand what each command does and how to use it.

Docker Commands


These docker commands don’t fit neatly into any category but are essential on their own. They help you get more out of docker.


Docker init

docker init → Creates Docker-related starter files for your project
Usage   : docker init [OPTIONS]
Aliases : NA

Description:

  • Requires:Docker Desktop 4.27 and later.
  • Initializes a project with all the files needed to run in a container.
  • Creates sensible defaults for:
    • .dockerignore
    • Dockerfile
    • compose.yaml (or overwrites docker-compose.yaml)
    • README.Docker.md
  • If files already exist, Docker warns you and asks if you want to overwrite. ⚠️ Overwritten files cannot be recovered, so back them up first.
  • Provides templates for different project types:
    • ASP.NET Core, Go, Java (Maven/uber jar), Node, PHP+Apache, Python, Rust, or a general-purpose “Other”.
  • After setup, you can customize the files for your project’s needs.
docker init
″”

docker search → Search Docker Hub for images
Usage   : docker search [OPTIONS] TERM
Aliases : NA

Description:

  • Searches Docker Hub for images.
  • Helps you find official or community images to use in your projects.
  • You can filter results with flags (e.g., stars, official, automated).
docker search
″”

Docker login

docker login → Authenticate to a registry (public or private)
Usage   : docker login [OPTIONS] [SERVER]
Aliases : NA

Description:

  • Credentials are stored in a credential store (more secure) or in config.json (less secure).
  • On Docker Desktop → credentials go into your OS keychain automatically.
  • Without Docker Desktop → you configure the credential store in $HOME/.docker/config.json (Linux) or %USERPROFILE%/.docker/config.json (Windows).
  • Authentication Method = Username + password or access token.
  • Docker Hub supports web-based sign-in and device code flow (secure default).
docker login
″”

Docker logout

docker logout → Logout from a registry
Usage   : docker logout [SERVER]
Aliases : NA

Description:

  • Logs you out from a registry. If no server is specified, Docker uses the default registry defined by the daemon.
docker logout
″”

Docker inspect

docker inspect → Return low-level information on Docker objects
Usage   : docker inspect [OPTIONS] NAME|ID [NAME|ID...]
Aliases : NA

Description:

  • Provides detailed information on Docker objects (containers, images, volumes, networks, etc.).
  • By default, results are shown in a JSON array.
  • Useful for debugging, auditing, or checking configuration details.
docker inspect
″”

Docker debug

docker debug → Get a shell into any container or image. An alternative to debugging with `docker exec`.
Usage   : debug [OPTIONS] {CONTAINER|IMAGE}
Aliases : NA

Description:

  • Requires:Docker Desktop 4.49 and later
  • Helps you debug slim images/containers that normally lack tools.
  • Opens a debug shell into any container or image, even if no shell exists.
  • Does not modify the actual image or container.
  • Comes with a toolbox (vim, nano, htop, curl, etc.) and supports bash, fish, zsh.
  • You can add/remove tools using built‑in commands:
    • install [tool] → add Nix packages
    • uninstall [tool] → remove packages
    • entrypoint → print, lint, or run entrypoint
    • builtins → list available built‑in tools
  • Changes in stopped images/containers are discarded when you exit.
  • For running/paused containers, changes are visible to the container but /nix stays hidden.

Docker Daemon

The Docker Daemon (dockerd) is the background service that manages Docker containers, images, networks, and volumes. It listens for Docker API requests and communicates with the Docker CLI (docker) to execute container operations. Without the daemon running, Docker commands won’t work.


Service Management

# Show the current status of the Docker service.
sudo systemctl status docker
# Start the Docker service.
sudo systemctl start docker
# Stop the Docker service
sudo systemctl start docker
# Restart the Docker service.
sudo systemctl restart docker
# Enable Docker to auto‑start on system boot.
sudo systemctl enable docker
# Disable Docker from auto‑starting on boot.
sudo systemctl disable docker

Configuration

Edit daemon settings: Config file is usually at /etc/docker/daemon.json in linux.

{
  "storage-driver": "overlay2",
  "log-level": "info",
  "insecure-registries": ["myregistry.local:5000"]
}
# After changes
sudo systemctl restart docker

Logs & Debugging

# Run daemon in debug mode
sudo dockerd --debug
# View daemon logs
journalctl -u docker


Updated on Dec 11, 2025