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.
<code>docker pull nginx</code>3. First Run of the Image
Run the container in detached mode and map host port 8090 to container port 80:
<code>docker run -d -p 8090:80 --name nginx-container nginx:latest</code>Sample output shows the container ID and confirms it is running.
4. Inspect Command
docker inspectprovides detailed information about containers, images, networks, volumes, etc.
<code>docker inspect nginx-container</code>5. Start an Existing Container
<code>docker start <container_id_or_name>
# or restart
docker restart <container_id_or_name></code>6. List Containers
<code>docker ps # running containers
docker ps -a # all containers</code>7. Stop a Container
<code>docker stop <container_id_or_name></code>8. Enter a Container
<code>docker exec -it <container_id_or_name> /bin/bash</code>Exiting the shell does not stop the container.
9. View Container Processes
<code>docker top <container_name></code>10. Delete a Container
<code>docker stop <container_id_or_name>
docker rm <container_id_or_name>
# Remove all stopped containers
docker rm $(docker ps -aq)</code>11. List Images
<code>docker images</code>12. Start All Containers
<code>docker start $(docker ps -a -q)</code>13. Modify Files Inside a Container
Method 1: Use
docker execwith an editor (e.g.,
vi).
<code>docker exec -it <container_id_or_name> bash
# then edit files inside the container</code>Method 2: Copy files out, edit on the host, and copy back.
<code>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/file</code>14. 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.
<code>docker network create --driver bridge --subnet 172.19.0.0/16 --gateway 172.19.0.1 mynet</code>15. View Network Modes
<code>docker network ls</code>16. Create a New Bridge Network
<code>docker network create --driver bridge --subnet 172.19.0.0/16 --gateway 172.19.0.1 dockercompose</code>17. Inspect Network Details
<code>docker network inspect dockercompose</code>18. Run a Container on the Custom Network with a Fixed IP
<code>docker run -it --name nginx-second --network=dockercompose --ip 172.19.0.6 nginx</code>Verify the IP with:
<code>docker inspect <container_id> | grep "IPAddress"</code>19. View Volume Information
<code>docker inspect -f {{.Volumes}} <container_name></code>These commands cover common Docker operations for image acceleration, container lifecycle management, networking, and file handling.
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.