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
-vto mount host directories or Docker volumes, allowing persistent data and configuration sharing between host and container. Example mounting
/var/lib/docker/volumes/html/_datato
/usr/share/nginx/htmlfor Nginx.
Custom Images and Dockerfile
Create a
Dockerfilewith 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
htmland
confdirectories.
Docker Compose
Define services (MySQL, application, Nginx) in a
docker-compose.ymlfile, specifying
container_name,
ports,
environment,
volumes, and
networks. Use
docker compose up -dto start all services together.
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.