Deploy the Mall Project on Linux with Just Two Docker‑Compose Scripts
This guide walks you through deploying the Mall e‑commerce application on a CentOS 7.6 server using Docker and two docker‑compose files, covering environment setup, required images, configuration of MySQL, Redis, Elasticsearch, RabbitMQ, Nginx, and the Mall services, plus firewall adjustments.
The simplest way to deploy the Mall project on Linux is to use two docker‑compose scripts: one for the dependent services (MySQL, Redis, Nginx, RabbitMQ, Elasticsearch, Kibana, Mongo) and another for the Mall applications (mall‑admin, mall‑search, mall‑portal).
Docker environment setup and usage
Refer to the "Essential Docker Commands for Developers" article for details.
Docker‑compose environment setup and usage
Refer to the "Deploy SpringBoot applications with Docker‑Compose" article for details.
Mall project docker‑compose deployment
Runtime configuration requirements
CentOS 7.6, recommended 4 GB RAM or more.
Deployment files
Database script mall.sql
Nginx configuration nginx.conf
docker-compose‑env.yml
docker-compose‑app.yml
Pre‑deployment preparation
Package and upload Mall application images
Build Docker images for mall‑admin, mall‑search, and mall‑portal. See the "Build Docker images for SpringBoot applications with Maven plugin" article.
Download required Docker images
docker pull mysql:5.7
docker pull redis:3.2
docker pull nginx:1.10
docker pull rabbitmq:3.7.15
docker pull elasticsearch:6.4.0
docker pull kibana:6.4.0
docker pull mongo:3.2Elasticsearch kernel parameters
# Change settings
sysctl -w vm.max_map_count=262144
# Apply immediately
sysctl -pCreate /mydata/elasticsearch/data directory and set permissions.
# Create directory
mkdir -p /mydata/elasticsearch/data
# Set permissions
chmod 777 /mydata/elasticsearch/dataNginx configuration
Copy the nginx.conf file to the host directory before mounting.
# Create directory and upload nginx.conf
mkdir -p /mydata/nginxExecute docker-compose‑env.yml
Upload the file to the Linux server and run docker‑compose up to start all dependent services.
version: '3'
services:
mysql:
image: mysql:5.7
container_name: mysql
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
volumes:
- /mydata/mysql/data:/var/lib/mysql
- /mydata/mysql/conf:/etc/mysql/conf.d
- /mydata/mysql/log:/var/log/mysql
redis:
image: redis:3.2
container_name: redis
command: redis-server --appendonly yes
volumes:
- /mydata/redis/data:/data
ports:
- 6379:6379
nginx:
image: nginx:1.10
container_name: nginx
volumes:
- /mydata/nginx/nginx.conf:/etc/nginx/nginx.conf
- /mydata/nginx/html:/usr/share/nginx/html
- /mydata/nginx/log:/var/log/nginx
ports:
- 80:80
rabbitmq:
image: rabbitmq:3.7.15-management
container_name: rabbitmq
volumes:
- /mydata/rabbitmq/data:/var/lib/rabbitmq
- /mydata/rabbitmq/log:/var/log/rabbitmq
ports:
- 5672:5672
- 15672:15672
elasticsearch:
image: elasticsearch:6.4.0
container_name: elasticsearch
environment:
- "cluster.name=elasticsearch"
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins
- /mydata/elasticsearch/data:/usr/share/elasticsearch/data
ports:
- 9200:9200
kibana:
image: kibana:6.4.0
container_name: kibana
links:
- elasticsearch:es
depends_on:
- elasticsearch
environment:
- "elasticsearch.hosts=http://es:9200"
ports:
- 5601:5601
mongo:
image: mongo:3.2
container_name: mongo
volumes:
- /mydata/mongo/db:/data/db
ports:
- 27017:27017Run the composition:
docker-compose -f docker-compose-env.yml up -dConfigure dependent services
After all services start, perform the following configurations.
MySQL
Create the mall database and a remote user reader .
Copy mall.sql into the MySQL container: docker cp /mydata/mall.sql mysql:/ Enter the container and execute:
# Enter container
docker exec -it mysql /bin/bash
# Connect to MySQL
mysql -uroot -proot --default-character-set=utf8
# Create remote user
GRANT ALL PRIVILEGES ON *.* TO 'reader'@'%' IDENTIFIED BY '123456';
# Create database
CREATE DATABASE mall CHARACTER SET utf8;
USE mall;
# Import schema
SOURCE /mall.sql;Elasticsearch
Install the Chinese analyzer IKAnalyzer and restart.
# Enter container
docker exec -it elasticsearch /bin/bash
# Install plugin
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.0/elasticsearch-analysis-ik-6.4.0.zip
# Restart
docker restart elasticsearchRabbitMQ
Create a mall user with a virtual host /mall .
Access the management UI at http://192.168.3.101:15672/ (login: guest/guest).
Create user mall with password mall and assign the administrator role.
Create virtual host /mall and grant the user permissions.
Execute docker-compose‑app.yml
Upload the file to the server and run docker‑compose up to start all Mall applications.
version: '3'
services:
mall-admin:
image: mall/mall-admin:1.0-SNAPSHOT
container_name: mall-admin
ports:
- 8080:8080
external_links:
- mysql:db
mall-search:
image: mall/mall-search:1.0-SNAPSHOT
container_name: mall-search
ports:
- 8081:8081
external_links:
- elasticsearch:es
- mysql:db
mall-portal:
image: mall/mall-portal:1.0-SNAPSHOT
container_name: mall-portal
ports:
- 8085:8085
external_links:
- redis:redis
- mongo:mongo
- mysql:db
- rabbitmq:rabbitRun the composition:
docker-compose -f docker-compose-app.yml up -dOpen the firewall to allow external access
systemctl stop firewalldAll services are now running
Recommended reading
Deploy SpringBoot applications with Docker‑Compose
Essential Docker commands for developers
Essential Linux commands for developers
Mall deployment on Linux (Docker)
Mall deployment on Windows
Mall skeleton with SpringBoot + MyBatis
Mall with Swagger‑UI for API docs
Mall with SpringSecurity and JWT (Part 1)
Mall with Elasticsearch for product search
Mall with MongoDB for document handling
Mall with RabbitMQ for delayed messages
Mall with OSS for file uploads
Welcome to follow, give a like!
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.
