Docker commands let you download images and run, inspect, and manage containers on a host. Kubernetes uses kubectl to send requests to the Kubernetes API server and manage cluster resources such as Pods. The commands below build a practical Docker foundation, then show how the workflows relate without implying that a container and a Pod are the same thing.
Docker images and containers: the basic distinction
A Docker image is the source used to create a container. A container is the running or stopped instance created from that image. An image reference may include a tag, such as nginx:alpine, or a digest. Docker’s documented form is docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]. Docker requires an image reference to create a container.
Use an image reference with docker run; use a container name or ID with commands such as docker exec, docker logs, and docker stop. These identifiers refer to different things.
Get oriented before running commands
docker --helpdisplays top-level help and available command groups.docker run --helpshows options for running containers.docker infodisplays information about the Docker Engine environment.
Docker’s CLI reference documents --help as the way to display command help. See the Docker CLI reference. Depending on how Docker is configured on your host, a command may require elevated privileges; follow your platform’s security guidance rather than changing permissions broadly.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
Run a container and follow its lifecycle
This example downloads an NGINX image, starts a named container, publishes a port, and demonstrates common container-management commands. It is an illustrative sequence; confirm that the image and shell suit your platform.
- Download the image:
docker pull nginx:alpine - List local images:
docker image ls - Start the container in the background:
docker run -d --name web -p 8080:80 nginx:alpine - List running containers:
docker ps - Read its logs:
docker logs web - Open a shell inside it:
docker exec -it web sh - Inspect its configuration and state:
docker inspect web - Stop it:
docker stop web - Remove the stopped container:
docker rm web
By default, docker run runs in the foreground; -d (or --detach) runs the container in the background. The -p 8080:80 option publishes container port 80 on host port 8080. Without port publishing, a container’s ports are not exposed to the host by default. Docker documents run options and port publishing.
The commands above use an explicit image tag. If you omit a tag, Docker defaults to latest; a tag is not inherently immutable. A digest is another way to identify an image. See Docker’s image-reference syntax.
The container’s writable layer is ephemeral: removing the container removes data stored there. Use a Docker volume for managed persistent data or a bind mount to share a host path with the container. Docker’s running-containers guide covers storage and mounts.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #3
What these Docker commands do
| Command | Purpose |
|---|---|
docker pull IMAGE |
Downloads an image. |
docker image ls |
Lists local images. |
docker run IMAGE |
Creates and starts a container from an image. |
docker ps |
Lists running containers; use docker ps -a to include stopped containers. |
docker logs CONTAINER |
Displays a container’s logs. |
docker exec -it CONTAINER COMMAND |
Runs a command in an existing container; -it provides an interactive terminal. |
docker inspect CONTAINER |
Displays detailed information about a container. |
docker stop CONTAINER |
Stops a running container. |
docker rm CONTAINER |
Removes a container. |
These commands manage containers through Docker’s command-line interface and Engine. See Docker’s container command reference.
Docker command equivalents in Kubernetes
Some Kubernetes commands serve a similar troubleshooting purpose, but they act on different objects and through a different control path. kubectl sends requests to the Kubernetes API server; it does not simply manage a standalone Docker container. A Pod is Kubernetes’ scheduling unit and may contain one or more containers. Learn how kubectl communicates with Kubernetes. Learn about Pods and Nodes.
| Docker workflow | Related Kubernetes command | How to interpret the relationship |
|---|---|---|
docker ps |
kubectl get pods |
Both list workloads, but one lists containers on a Docker host and the other lists Pods in a Kubernetes namespace. A Pod can contain multiple containers. |
docker logs CONTAINER |
kubectl logs POD |
Reads workload logs. For a multi-container Pod, specify the container with -c CONTAINER. |
docker exec -it CONTAINER sh |
kubectl exec -it POD -- sh |
Runs a command in a container. Kubernetes targets a Pod and uses -- to separate kubectl options from the command; identify a container when the Pod has more than one. |
docker inspect CONTAINER |
kubectl describe pod POD |
describe gives human-readable details about a Kubernetes resource. It is not a universal JSON-equivalent replacement for Docker inspect, and its output is not a stable scripting interface. |
docker run IMAGE |
kubectl run or a Deployment manifest |
These can start workloads, but Kubernetes manages API objects and desired state rather than just one host-level container. |
The Docker-to-kubectl reference provides examples of corresponding command patterns, not exact one-to-one behavior. See the Kubernetes Docker-to-kubectl reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.From an imperative command to a repeatable Kubernetes workload
A Docker command such as docker run IMAGE is an imperative instruction to start a container. Kubernetes can also create a workload from a command, but for production management Kubernetes recommends applying version-controlled declarative configuration with kubectl apply. That configuration records the desired state so it can be reviewed and reapplied. Read the kubectl overview.
Best Value
Remember the distinction when moving from local practice to a cluster: Docker CLI operations target containers through a Docker Engine, while Kubernetes operations target API resources across a cluster. Kubernetes nodes use a container runtime; Kubernetes does not necessarily use Docker Engine as that runtime.
Quick Recap
Common mistakes to avoid
- Using an image where a container is required:
docker runneeds an image reference;docker execneeds the name or ID of an existing container. - Expecting host access without publishing a port: use
-por-Pwhen a container port needs to be reachable from the host. - Assuming container-local data survives removal: store persistent data in a volume or bind mount, not only in the writable layer.
- Treating Kubernetes Pods as Docker containers: the Pod is a Kubernetes scheduling object and may group multiple containers.
- Scripting against
kubectl describeoutput: it is intended for people to read, not as a stable machine-readable interface.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

