Speed Up Docker Pulls and Master Container Management with Simple Commands
This guide shows how to configure Docker registry mirrors for faster image pulls, run and manage containers—including starting, inspecting, networking, and file editing—using concise command‑line examples and practical tips for Linux environments.
2. Pull an Image
Example: pull the latest Nginx image.
docker pull nginx3. First Run of the Image
Run the container in detached mode and map host port 8090 to container port 80:
docker run -d -p 8090:80 --name nginx-container nginx:latestSample output shows the container ID and confirms it is running.
4. Inspect Command
docker inspectprovides detailed information about containers, images, networks, volumes, etc.
docker inspect nginx-container5. Start an Existing Container
docker start <container_id_or_name>
# or restart
docker restart <container_id_or_name>6. List Containers
docker ps # running containers
docker ps -a # all containers7. Stop a Container
docker stop <container_id_or_name>8. Enter a Container
docker exec -it <container_id_or_name> /bin/bashExiting the shell does not stop the container.
9. View Container Processes
docker top <container_name>10. Delete a Container
docker stop <container_id_or_name>
docker rm <container_id_or_name>
# Remove all stopped containers
docker rm $(docker ps -aq)11. List Images
docker images12. Start All Containers
docker start $(docker ps -a -q)13. Modify Files Inside a Container
Method 1: Use docker exec with an editor (e.g., vi).
docker exec -it <container_id_or_name> bash
# then edit files inside the containerMethod 2: Copy files out, edit on the host, and copy back.
docker cp <container_id_or_name>:/path/to/file /host/path
# edit the file on the host
docker cp /host/path/file <container_id_or_name>:/path/to/file14. Create a Container with a Specific IP
Docker’s default bridge network assigns IPs automatically. For fixed IPs, create a custom bridge network and run the container on it.
docker network create --driver bridge --subnet 172.19.0.0/16 --gateway 172.19.0.1 mynet15. View Network Modes
docker network ls16. Create a New Bridge Network
docker network create --driver bridge --subnet 172.19.0.0/16 --gateway 172.19.0.1 dockercompose17. Inspect Network Details
docker network inspect dockercompose18. Run a Container on the Custom Network with a Fixed IP
docker run -it --name nginx-second --network=dockercompose --ip 172.19.0.6 nginxVerify the IP with:
docker inspect <container_id> | grep "IPAddress"19. View Volume Information
docker inspect -f {{.Volumes}} <container_name>These commands cover common Docker operations for image acceleration, container lifecycle management, networking, and file handling.
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.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
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.
