Essential Docker Commands for Daily Container Workflows

Launching and Managing Containers

# Spin up an interactive Ubuntu shell
docker run -it --rm ubuntu:22.04 bash

# Run a detached Nginx container, map host port 8080
docker run -d -p 8080:80 --name web nginx

Listing Rseources

# Show only active containers
docker ps

# Show every container, running or stopped
docker ps -a

# Display locally cached images
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"

Sample output:

REPOSITORY    TAG       SIZE
nginx         latest    142MB
ubuntu        22.04     77.8MB

Controlling Container Lifecycle

# Gracefully stop a container
docker stop web

# Resume a paused container
docker start web

# Forcefully terminate
docker kill web

# Remove a stopped container
docker rm web

Debugging and Introspection

# Stream stdout/stderr from a container
docker logs -f web

# Execute an extra process inside a running container
docker exec -it web sh

# Copy files between host and container
docker cp ./app.js web:/usr/share/nginx/html/

Building and Shipping Images

# Build from Dockerfile in current directory
docker build -t myapi:1.0 .

# Tag for registry upload
docker tag myapi:1.0 registry.example.com/team/myapi:1.0

# Push to remote registry
docker push registry.example.com/team/myapi:1.0

# Remove unused images
docker rmi registry.example.com/team/myapi:1.0

Frequently Used Base Images

Image Purpose
nginx High-performance HTTP server and reverse proxy
alpine Minimal, security-oriented Linux distro (~5 MB)
busybox Swiss-army knife of Unix utilities in a tiny footprint
ubuntu Full-featured Debian-based OS for general workloads

Find more images on Docker Hub.

Tags: docker containers CLI devops cheatsheet

Posted on Sat, 09 May 2026 15:33:42 +0000 by GodzMessanja