Speed Up Docker Pulls: Configure Registry Mirrors & Manage Containers
Learn how to accelerate Docker image pulls by configuring registry mirrors, then follow step‑by‑step instructions to pull, run, inspect, and manage Nginx containers, including commands for starting, stopping, logging, networking, and modifying container files, ensuring efficient container operations.
1. Configure Registry Mirrors
Create or edit /etc/docker/daemon.json and add a registry-mirrors array with mirror URLs, for example:
{
"registry-mirrors": [
"https://dockerproxy.com",
"https://docker.chenby.cn",
"https://dockerpull.com",
"https://dockerhub.jobcher.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub.uuuadc.top",
"https://mirror.baidubce.com",
"https://mirror.ccs.tencentyun.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://hus-mirror.c.163.com",
"https://dockerhub.azk8s.cn",
"https://registry.cn-hangzhou.aliyuncs.com"
]
}Save the file, then reload the daemon and restart Docker:
sudo systemctl daemon-reload
sudo systemctl restart dockerVerify the configuration with docker info and check that the Registry Mirrors section lists the added URLs.
2. Pull an Image
Example pulling the Nginx image:
docker pull nginx3. First Run of the Image
docker run -d -p 8090:80 --name nginx-container nginx:latestSample commands to view images and containers:
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 5ef79149e0ec 10 days ago 188MB
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
96a5d9d25052 nginx:latest "/docker-entrypoint.…" 19 seconds ago Up 18 seconds 0.0.0.0:8090->80/tcp nginx-containerParameter explanations:
-d runs the container in detached mode.
-p 8090:80 maps host port 8090 to container port 80.
--name assigns a name to the container.
nginx:latest specifies the image to use.
-it combines interactive and TTY flags.
-v mounts a volume (optional).
--volumes-from mounts volumes from another container.
4. View Logs
docker logs 96a5d9d250525. Inspect Command
The docker inspect command shows detailed information about Docker objects. docker inspect [OPTIONS] NAME|ID [NAME|ID...] Example to inspect a container:
docker inspect nginx-container6. Start an Existing Container
docker start <container_id_or_name>
docker restart <container_id_or_name>7. List Containers
docker ps # running containers
docker ps -a # all containers8. Stop a Container
docker stop <container_id_or_name>9. Enter a Container
docker exec -it <container_id_or_name> /bin/bashExiting the shell does not stop the container.
10. View Container Processes
docker top <container_name>11. Remove a Container
docker stop <container_id_or_name>
# then
docker rm <container_id_or_name>
# remove all stopped containers
docker rm $(docker ps -aq)12. List Images
docker images13. Start All Containers
docker start $(docker ps -a -q)14. Modify Files Inside a Container
Method 1: Use an editor inside the container
docker exec -it <container_id_or_name> bash
# then use vi, nano, etc., e.g.:
vi /path/to/fileMethod 2: Copy files from/to the host
# Copy from container to host
docker cp <container_id_or_name>:/path/to/file /host/path
# Edit the file on the host, then copy back
docker cp /host/path/file <container_id_or_name>:/path/to/file15. Create a Container with a Specific IP
Docker’s default bridge network assigns IPs automatically. To use fixed IPs, create a custom bridge network:
docker network create --driver bridge --subnet=172.19.0.0/16 --gateway=172.19.0.1 mynetRun a container on this network with a chosen IP:
docker run -it --name nginx-second --network=mynet --ip 172.19.0.6 nginxVerify the IP:
docker inspect <container_id> | grep "IPAddress"16. View Network Information
docker network ls17. Inspect a Network
docker network inspect mynet18. View Volume Information
docker inspect -f {{.Volumes}} <container_name>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.
