Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

Kubernetes Day 4: Essential Docker Commands and Their kubectl Counterparts

A practical Docker command walkthrough for Kubernetes learners, with a clear distinction between standalone containers and Kubernetes Pods.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Docker commands help you work with images and standalone containers on a host; Kubernetes commands such as kubectl manage Pods and other resources through the Kubernetes API. Learning the Docker container lifecycle is useful preparation for Kubernetes, but there is no one-to-one command mapping because the tools operate on different objects and at different scales.

Docker images and containers are different

A Docker image is the source used to create a container. An image reference can include a tag or digest; Docker documents the general form as docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]. A container is the created, running or stopped instance. Use an image reference with docker run; use a container name or ID with commands such as docker exec and docker stop. Docker states that the docker run command must specify an image reference to create the container from (Docker: Running containers).

As an Amazon Associate I earn from qualifying purchases.

If you omit the tag, Docker uses latest. For more repeatable examples, specify a tag; where exact image identity matters, use a digest. A tag is not inherently immutable. Docker may also require sudo depending on how access is configured on the host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Orient yourself before running commands

  • docker --help lists Docker CLI commands and general help.
  • docker run --help shows options for creating and starting a container.
  • docker info provides information about the Docker environment when that detail is relevant.

The Docker CLI reference documents --help for command help and describes the available command families (Docker CLI reference).

Run through a basic container lifecycle

This illustrative sequence downloads an Nginx image, starts a named container, checks it, and removes it. It assumes Docker is installed and available on the host. The image’s shell and behavior can vary by image and platform.

  1. Download an image: docker pull nginx:alpine
  2. List local images: docker image ls
  3. Start a container and publish a port: docker run -d --name web -p 8080:80 nginx:alpine. Here -d runs it in the background, and -p 8080:80 maps host port 8080 to container port 80.
  4. List running containers: docker ps. To include stopped containers, use docker ps -a.
  5. Read its logs: docker logs web.
  6. Open a shell in the running container: docker exec -it web sh. This works only if the container has a compatible sh shell.
  7. Inspect container details: docker inspect web.
  8. Stop the container: docker stop web.
  9. Remove the stopped container: docker rm web.

By default, docker run attaches to the foreground; use -d or --detach to run in the background. Published ports are needed when a service inside the container must be reached through the host; container ports are not exposed to the host by default. The command syntax and container lifecycle operations are covered in Docker’s running containers guide and container command reference.

Understand what persists and what does not

A container’s writable layer is ephemeral by default. Removing the container removes data stored only in that layer. Use a Docker volume when data should persist independently of the container, or a bind mount when you need to share a host path with it. Choose and configure storage deliberately before removing a container that holds data you need.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Docker commands relate to kubectl

The commands below address similar learning tasks, but they do not manage equivalent objects. Docker’s CLI communicates with Docker Engine to manage containers on a host. kubectl sends requests to the Kubernetes API server to work with cluster resources. A Pod is Kubernetes’ scheduling unit and may contain one or more containers; Kubernetes nodes use a container runtime, and Kubernetes does not necessarily run Docker Engine as that runtime.

Docker task Kubernetes command or workflow Important difference
docker ps kubectl get pods Docker lists containers on a host; this Kubernetes command lists Pods in a namespace. A Pod can contain multiple containers.
docker logs CONTAINER kubectl logs POD Kubernetes logs target a container in a Pod. For a multi-container Pod, specify the container when needed.
docker exec -it CONTAINER sh kubectl exec -it POD -- sh Kubernetes targets a Pod and, where necessary, a container within it. The -- separates kubectl options from the command being run.
docker inspect CONTAINER kubectl describe pod POD (partial analogue) describe provides human-readable resource details; it is not a universal JSON-equivalent inspection command or stable scripting interface.
docker run IMAGE kubectl run or a Deployment manifest, depending on the task Kubernetes manages API objects and desired state rather than simply starting a standalone container. For production management, Kubernetes recommends declarative, version-controlled configuration.

Kubernetes documents examples for mapping Docker CLI habits to kubectl workflows in its Docker-to-kubectl reference. The kubectl overview explains how kubectl communicates user intent to the API.

Use kubectl to troubleshoot Kubernetes workloads

For a workload running in Kubernetes, investigate the Kubernetes resources rather than assuming a local Docker container is the target. These common operations help locate a Pod, review its details and logs, and run a command inside it:

  • kubectl get pods lists Pods in the current namespace.
  • kubectl describe pod POD shows human-readable details about a Pod and its events.
  • kubectl logs POD retrieves logs; specify a container when the Pod has more than one.
  • kubectl exec -it POD -- sh runs a shell command in a container in the Pod, if that container includes a compatible shell.

The Kubernetes Pods and Nodes tutorial presents these as common ways to explore and troubleshoot workloads. Because kubectl describe is intended for people to read, do not treat its output as a stable machine-readable interface.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the right mental model

  • Target: Docker commands act on images or containers; kubectl acts on Pods and other Kubernetes API resources.
  • Control path: Docker CLI commands control Docker Engine; kubectl communicates with the Kubernetes API server.
  • Scope: Docker’s basic container workflow is host-oriented; Kubernetes schedules workloads across a cluster and manages declared desired state.
  • Repeatability: An imperative command can start an individual container or create a resource, while version-controlled declarative manifests make Kubernetes configuration easier to review and manage consistently.

For a learner moving from Docker to Kubernetes, first recognize the image, container, logs, execution, and lifecycle concepts. Then learn how Kubernetes expresses and observes those ideas through Pods and other API resources, rather than looking for a direct replacement for every Docker command.

Best Value
Docker Container Linux Devops Programming Coding T-Shirt
  • Docker, Docker Swarm, Docker Compose, Programmer, Developer, Coding, Programming, Software Engineer, Code, DevOps, Deploy, Deployment, Kubernetes, Salt, Puppet, Chef, Terraform, Container, AWS, Azure, Cloud, Geek, Funny, Computer, Software, Tech, IT
  • Integration, Scrum, Compile, Compilation, Science, Bug, Debug, Python, Linux, Java, Javascript, Scala, Dotnet, Kotlin
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.