Master Docker Deployment: From Installation to Advanced Container Management
This comprehensive guide walks you through Docker fundamentals, Linux installation steps, essential commands, data volume handling, custom image creation with Dockerfiles, networking tricks, full project deployment, and using Docker Compose to orchestrate multi‑service applications, all illustrated with practical code examples.
Docker Installation
Install Docker on CentOS by removing old versions, adding the yum repository, installing packages, starting the service and verifying with docker ps.
Common Docker Commands
docker pull – download images
docker run – create and start a container (example:
docker run -d --name mysql -p 3306:3306 -e TZ=Asia/Shanghai -e MYSQL_ROOT_PASSWORD=123 mysql)
docker ps – list running containers
docker stop / start / rm – manage container lifecycle
docker logs – view container output
Data Volumes
Use -v to mount host directories or Docker volumes, allowing persistent data and configuration sharing between host and container. Example mounting /var/lib/docker/volumes/html/_data to /usr/share/nginx/html for Nginx.
Custom Images and Dockerfile
Create a Dockerfile with instructions such as FROM , COPY , RUN , EXPOSE , and ENTRYPOINT to build layered images. Build with docker build -t myapp:1.0 . and run the image.
Networking
Create a user‑defined bridge network ( docker network create mynet) and connect containers with aliases so they can reach each other by name without IP addresses.
Project Deployment
Package a Java application into a JAR, write a Dockerfile, build the image, and run it with port mapping. Deploy a static front‑end using an Nginx container with volume mounts for html and conf directories.
Docker Compose
Define services (MySQL, application, Nginx) in a docker-compose.yml file, specifying container_name, ports, environment, volumes, and networks. Use docker compose up -d to start all services together.
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.
Ops Community
A leading IT operations community where professionals share and grow together.
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.
