Master Docker: From Basics to Advanced Container Management
This comprehensive guide introduces Docker’s origins, core concepts such as images, containers, and registries, walks through installation, daemon configuration, essential commands, building and managing images, running containers interactively or in background, and explains import/export, tagging, and repository usage, providing practical examples throughout.
Quick Start
Docker originated as an internal side project at dotCloud, written in Go, aiming to provide a lightweight OS‑level virtualization solution based on Linux containers (LXC). Containers start in seconds, use resources efficiently, and allow thousands of instances on a single host.
Compared with traditional VM virtualization, containers share the host OS kernel, resulting in faster startup and higher resource utilization.
Installation
Official Docker packages are available for Mac, Linux and Windows; follow the official documentation. The graphical tool Kitematic (Visual Docker Container Management on Mac & Windows) can help beginners.
Daemon
Run the Docker daemon with a custom bind address, e.g. sudo /usr/bin/docker -d -H tcp://0.0.0.0:2375, or set export DOCKER_HOST="tcp://0.0.0.0:2375" to avoid typing the full command each time.
GUI tools
Web management interfaces such as Shipyard and Portainer simplify container operations.
Basic Concepts
Image : a read‑only template stored in a layered UnionFS; used to create containers.
Container : a runnable instance of an image with an additional writable layer; isolated filesystem, process space, and network.
Registry : a service that stores images (public Docker Hub, private registries, Docker Pool, etc.). Images can be pushed and pulled using docker push and docker pull.
Docker enables consistent development, testing, and deployment across environments.
Common Commands
Check Docker status: sudo docker info List running containers: docker ps (add -a for all, -l for the latest)
Running Containers
Example: docker run ubuntu:14.04 /bin/echo 'Hello wdx!' prints the message.
Interactive mode: docker run -t -i ubuntu:14.04 /bin/bash (‑t allocates a pseudo‑TTY, ‑i keeps STDIN open).
Inside the container you can inspect processes with ps or top, view /etc/hosts, check network with ip a, etc.
Images
Pull images with docker pull ubuntu:12.04 or from a custom registry. List local images using docker images. Build custom images with a Dockerfile and docker build -t myimage ..
Running Images
Search Docker Hub for images such as whalesay and run them: docker run docker/whalesay cowsay boo.
Creating Images
Write a Dockerfile, e.g.:
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsayBuild with sudo docker build -t wdx-whale . and run docker run wdx-whale.
Managing Images
Export an image: docker save -o wdx-local-whale.tar wdxtub/wdx-whale. Import with docker load --input wdx-local-whale.tar. Delete dangling images with sudo docker rmi $(docker images -q -f "dangling=true").
Container Lifecycle
Start containers in background with -d. View logs using docker logs <containerid>. Stop with docker stop <containerid>, restart with docker restart <containerid>. Export a container with docker export <containerid> and import it as an image with docker import.
Registries and Repositories
A repository stores images; a registry is the server that hosts one or more repositories. Public Docker Hub is the most common registry.
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.
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.
