Common Kubernetes and Docker Commands
This article provides a concise reference of frequently used Kubernetes (kubectl) and Docker command‑line instructions, covering cluster inspection, pod and service queries, resource creation, deletion, as well as container inspection, logging, and interactive shell access.
Kubernetes (kubectl) Common Commands
View cluster information kubectl cluster-info View component statuses
kubectl -s http://localhost:8080 get componentstatusesShow pods with node information kubectl get pods -o wide Display pod definitions in YAML kubectl get pods -o yaml List Replication Controllers kubectl get rc List services kubectl get service List nodes kubectl get nodes Find pods by selector kubectl get pod --selector name=redis Show environment variables of a running pod
kubectl exec <span style="color:#e6c07b;">pod-name</span> envCreate resources from a file kubectl create -f filename Replace resources (optional force) kubectl replace -f filename [--force] Delete resources
kubectl delete -f filename kubectl delete pod pod-name kubectl delete rc rc-name kubectl delete service service-name kubectl delete pod --allDocker Container Common Commands
List running containers docker ps List all containers docker ps -a Show container IP docker exec ContainerID hostname -i View container logs (follow) docker logs -f ContainerID Enter a Linux container interactively
docker run -it imageID /bin/bash docker run -i -t imageID /bin/bashAttach to a running container
docker attach db3 docker attach d48b21a7e439Note: db3 is the container name (NAMES) and d48b21a7e439 is the container ID (CONTAINER ID). Using docker exec -it ContainerID /bin/bash provides an interactive shell that remains active after exiting the command, unlike a simple docker attach which terminates the container when exit is issued.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack Internet Architecture
Introducing full-stack Internet architecture technologies centered on Java
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
