Step‑by‑Step: Deploy the Mall Application on Linux Using Docker
This guide walks you through installing Docker on CentOS 7.6 and deploying a complete mall stack—including MySQL, Redis, Nginx, RabbitMQ, Elasticsearch, MongoDB, and a SpringBoot service—inside Docker containers, configuring volumes, ports, firewalls, and testing the APIs.
Docker Environment Installation
Install yum-utils with yum install -y yum-utils device-mapper-persistent-data lvm2 Add Docker repository:
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoInstall Docker CE: yum install -y docker-ce Start Docker:
systemctl start dockerMySQL Installation
Pull image: docker pull mysql:5.7 Run container:
docker run -p 3306:3306 \
-v /mydata/mysql/conf:/etc/mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7Enter container: docker exec -it mysql /bin/bash Connect with client: mysql -uroot -proot --default-character-set=utf8 Create database: create database mall character set utf8 Create user reader with remote access:
grant all privileges on *.* to 'reader'@'%' identified by '123456';Redis Installation
Pull image: docker pull redis:3.2 Run container:
docker run -p 6379:6379 \
-v /mydata/redis/data:/data \
-d redis:3.2 --appendonly yesConnect:
docker exec -it redis redis-cliNginx Installation
Pull image: docker pull nginx:1.10 Copy configuration from a temporary container, then run:
docker run -p 80:80 \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-d nginx:1.10RabbitMQ Installation
Pull image: docker pull rabbitmq:3.7.15 Run container with required ports:
docker run -d --name rabbitmq \
-p 5671:5671 -p 5672:5672 \
-p 4369:4369 -p 25672:25672 \
-p 15671:15671 -p 15672:15672 \
rabbitmq:3.7.15Enable management plugin:
docker exec -it rabbitmq rabbitmq-plugins enable rabbitmq_managementOpen firewall for port 15672.
Elasticsearch Installation
Pull image: docker pull elasticsearch:6.4.0 Increase virtual memory: sysctl -w vm.max_map_count=262144 Run container:
docker run -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e "cluster.name=elasticsearch" \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-d elasticsearch:6.4.0Install IKAnalyzer plugin inside the container and restart.
Open firewall for port 9200.
Kibana Installation
Pull image: docker pull kibana:6.4.0 Run container linked to Elasticsearch:
docker run --name kibana -p 5601:5601 \
--link elasticsearch:es \
-e "elasticsearch.hosts=http://es:9200" \
-d kibana:6.4.0Open firewall for port 5601.
MongoDB Installation
Pull image: docker pull mongo:3.2 Run container:
docker run -p 27017:27017 \
-v /mydata/mongo/db:/data/db \
-d mongo:3.2Docker Full‑Stack Completion
All images downloaded and containers running (see screenshots).
SpringBoot Application Deployment
Build Docker Images and Push
Uncomment Docker plugin in pom.xml, set dockerHost to your server, then build and push images.
Deploy mall‑admin
docker run -p 8080:8080 --name mall-admin \
--link mysql:db \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/admin/logs:/var/logs \
-d mall-admin:1.0-SNAPSHOTDeploy mall‑search
docker run -p 8081:8081 --name mall-search \
--link elasticsearch:es \
--link mysql:db \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/search/logs:/var/logs \
-d mall-search:1.0-SNAPSHOTDeploy mall‑portal
docker run -p 8085:8085 --name mall-portal \
--link mysql:db \
--link redis:redis \
--link mongo:mongo \
--link rabbitmq:rabbit \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/portal/logs:/var/logs \
-d mall-portal:1.0-SNAPSHOTOpen Required Ports
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --zone=public --add-port=8085/tcp --permanent
firewall-cmd --reloadAPI Testing
mall‑admin: http://<your‑ip>:8080/swagger-ui.html mall‑search: http://<your‑ip>:8081/swagger-ui.html mall‑portal:
http://<your‑ip>:8085/swagger-ui.htmlRecommended Reading
Using Maven Plugin to Build Docker Images
Essential Docker Commands for Developers
Essential Linux Commands for Developers
Follow the guide and enjoy a fully containerized mall deployment!
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.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.
