Essential Docker Commands: From Images to Containers and Registry
This guide walks through fundamental Docker commands for inspecting Docker versions, managing images, running and inspecting containers, committing changes, handling container lifecycle, saving/loading images, logging into registries, and publishing images to a registry.
1. View Docker Information
Check Docker version: docker version Show system information:
docker info2. Image Operations
Search for an image: docker search image_name Download an image: docker pull image_name List images: docker images Remove one or more images: docker rmi image_name Show image history:
docker history image_name3. Run Containers
Run a container to echo "hello word": docker run image_name echo "hello word" Start an interactive shell: docker run -i -t image_name /bin/bash Install a program inside a container:
docker run image_name apt-get install -y app_name4. Inspect Containers
List running containers: docker ps List all containers: docker ps -a Show the most recently started container:
docker ps -l5. Save Container Changes
Create a new image from a container:
docker commit ID new_image_name6. Container Management
Remove all containers: docker rm `docker ps -a -q` Remove a single container: docker rm Name/ID Stop, start, or kill a container: docker stop Name/ID, docker start Name/ID, docker kill Name/ID Fetch container logs: docker logs Name/ID Show changed files/directories: docker diff Name/ID Display processes inside a container: docker top Name/ID Copy files from container to host: docker cp Name:/container_path to_path or docker cp ID:/container_path to_path Restart a running container: docker restart Name/ID Attach to a running container:
docker attach ID7. Save and Load Images
Export an image to a tar file: docker save image_name -o file_path Import an image from a tar file:
docker load -i file_path8. Login to Registry
Log in to a Docker registry:
docker login9. Publish Image
Push an image to a registry:
docker push new_image_nameSigned-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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
