Docker容器的Web应用系统部署
# 基于Docker容器的Web应用系统部署
创建一个项目叫做Work的在里面完成任务,分别再创建redis,mariabd,kafka,zookeeper,nginx,docker-compose。
# 【题目1】Redis容器化
在master节点上编写/root/redis/Dockerfile文件构建chinaskill-redis:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)修改配置文件中的bind 127.0.0.1为bind 0.0.0.0;
(4)设置Redis免密,并关闭保护模式;
(5)开放端口:6379;
(6)设置服务开机自启。
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
RUN yum install -y redis
EXPOSE 6379
RUN sed -i -e "s/^bind 127.0.0.1/bind 0.0.0.0/g" /etc/redis.conf
RUN sed -i -e "s/^protected-mode yes/protected-mode no/g" /etc/redis.conf
ENTRYPOINT ["/usr/bin/redis-server","/etc/redis.conf"]
[root@master redis]# docker build -t='chinaskill-redis:v1.1' .
# 【题目2】Mariadb容器化
在master节点上编写/root/mariadb/Dockerfile文件构建chinaskill-mariadb:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)设置数据库密码:123456;
(4)创建数据库gpmall并导入数据库文件gpmall.sql;
(5)设置数据库字符编码:UTF-8;
(6)开放端口:3306;
(7)设置服务开机自启。
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
RUN yum install -y mariadb mariadb-server
COPY run.sh /root/
COPY gpmall.sql /root/
RUN chmod a+x /root/run.sh && /root/run.sh
ENV LC_ALL en_US.UTF-8
EXPOSE 3306
CMD mysqld_safe
[root@master mariadb]# cat run.sh
#!/bin/bash
sleep 5
mysqld_safe &
sleep 5
mysqladmin -uroot password 123456
mysql -uroot -p123456 -e "grant all on *.* to root@'%' identified by '123456'; "
mysql -uroot -p123456 -e "create database gpmall;use gpmall;source /root/gpmall.sql; "
[root@master redis]# docker build -t='chinaskill-mariadb:v1.1' .
# 【题目3】Zookeeper容器化
在master节点上编写/root/zookeeper/Dockerfile文件构建chinaskill-zookeeper:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)开放端口:2181;
(4)设置服务开机自启。
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN mkdir /opt/zookeeper
ADD zookeeper-3.4.14.tar.gz /opt/zookeeper/
RUN echo "source /root/.bash_profile" > /opt/zookeeper/start.sh &&\
echo "cp /opt/zookeeper/zookeeper-3.4.14/conf/zoo_sample.cfg /opt/zookeeper/zookeeper-3.4.14/conf/zoo.cfg" >> /opt/zookeeper/start.sh &&\
echo "/opt/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start-foreground" >> /opt/zookeeper/start.sh
EXPOSE 2181
ENTRYPOINT ["sh","/opt/zookeeper/start.sh"]
[root@master zookeeper]# docker build -t='chinaskill-zookeeper:v1.1' .
# 【题目4】Kafka容器化
在master节点上编写/root/kafka/Dockerfile文件构建chinaskill-kafka:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)开放端口:9092;
(4)设置服务开机自启。
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN mkdir /opt/kafka
ADD kafka_2.11-1.1.1.tgz /opt/kafka
RUN sed -i -e "s/num.partitions.*$/num.partitions=3/g" /opt/kafka/kafka_2.11-1.1.1/config/server.properties
RUN echo "source /root/.bash_profile" > /opt/kafka/start.sh &&\
echo "cd /opt/kafka/kafka_2.11-1.1.1">> /opt/kafka/start.sh &&\
echo "sed -i 's%zookeeper.connect=.*$%zookeeper.connect=zookeeper:2181%g' /opt/kafka/kafka_2.11-1.1.1/config/server.properties" >> /opt/kafka/start.sh &&\
echo "bin/kafka-server-start.sh config/server.properties" >> /opt/kafka/start.sh &&\
chmod a+x /opt/kafka/start.sh
EXPOSE 9092
ENTRYPOINT ["sh","/opt/kafka/start.sh"]
[root@master zookeeper]# docker build -t='chinaskill-kafka:v1.1' .
# 【题目5】Nginx容器化
在master节点上编写/root/nginx/Dockerfile文件构建chinaskill-nginx:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)编写/etc/nginx/conf.d/default.conf文件,配置反向代理,将80端口请求转发到8081、8082和8083;
(4)将dist中的文件复制到/usr/share/nginx/html/目录下;
(5)复制所有的jar包到镜像中;
(6)开放端口:80、443、8081、8082、8083;
(7)设置服务开机自启。
[root@master nginx]# ll
total 199340
-rw-r--r--. 1 root root 1312 May 5 10:19 default.conf
drwxr-xr-x. 3 root root 38 May 5 10:20 dist
-rw-r--r--. 1 root root 673 May 5 10:19 Dockerfile
-rw-r--r--. 1 root root 177 May 5 10:08 ftp.repo
-rw-r--r--. 1 root root 47765224 Nov 11 11:22 gpmall-shopping-0.0.1-SNAPSHOT.jar
-rw-r--r--. 1 root root 39005468 Nov 11 11:22 gpmall-user-0.0.1-SNAPSHOT.jar
-rw-r--r--. 1 root root 727 Nov 10 17:14 index.html
-rw-r--r--. 1 root root 270 Nov 11 11:27 run.sh
-rw-r--r--. 1 root root 54936064 Nov 11 11:22 shopping-provider-0.0.1-SNAPSHOT.jar
drwxr-xr-x. 10 root root 101 Nov 10 17:14 static
-rw-r--r--. 1 root root 62386947 Nov 11 11:22 user-provider-0.0.1-SNAPSHOT.jar
FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN mv /etc/yum.repos.d/* /media
COPY ftp.repo /etc/yum.repos.d/
RUN yum -y install nginx java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN mv /usr/share/nginx/html/* /media/
COPY index.html /usr/share/nginx/html/
COPY static/ /usr/share/nginx/html/static
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY default.conf /etc/nginx/conf.d/default.conf
COPY *.jar /opt/
EXPOSE 80 443 8081 8082 8083
COPY run.sh /opt/
RUN chmod +x /opt/run.sh
CMD ["/opt/run.sh"]
[root@master nginx]# cat run.sh
#!/bin/bash
cd /opt/
nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
sleep 5
nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &
sleep 5
nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
sleep 5
nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &
sleep 5
nginx
[root@master nginx]# cat default.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /user {
proxy_pass http://127.0.0.1:8082;
}
location /shopping {
proxy_pass http://127.0.0.1:8081;
}
location /cashier {
proxy_pass http://127.0.0.1:8083;
}
}
[root@master nginx]# docker build -t='chinaskill-nginx:v1.1' .
# 【题目6】docker-compose编排
在master节点上编写/root/chinaskillmall/docker-compose.yaml文件部署,具体要求如下:
(1)容器1名称:mall-mysql;镜像:chinaskill-mariadb:v1.1;端口映射:13306:3306;
(2)容器2名称:mall-redis;镜像:chinaskill-redis:v1.1;端口映射:16379:6379;
(3)容器3名称:mall-kafka;镜像:chinaskill-kafka:v1.1;端口映射:19092:9092;
(4)容器4名称:mall-zookeeper;镜像:chinaskill-zookeeper:v1.1;端口映射:12181:2181;
(5)容器5名称:mall-nginx;镜像:chinaskill-nginx:v1.1;端口映射:83:80,1443:443;自启动所有的jar包程序。
# cat docker-compose.yaml
version: "3"
services:
mysql.mall:
container_name: mysql
image: chinaskill-mariadb:v1.1
ports:
- "3306:3306"
restart: always
redis.mall:
depends_on:
- mysql.mall
container_name: redis
image: chinaskill-redis:v1.1
ports:
- "6379:6379"
restart: always
zookeeper.mall:
depends_on:
- mysql.mall
- redis.mall
container_name: zookeeper
image: chinaskill-zookeeper:v1.1
ports:
- "2181:2181"
restart: always
kafka.mall:
links:
- zookeeper.mall
depends_on:
- mysql.mall
- redis.mall
- zookeeper.mall
container_name: kafka
image: chinaskill-kafka:v1.1
ports:
- "9092:9092"
restart: always
mall:
container_name: nginx
image: chinaskill-nginx:v1.1
links:
- mysql.mall
- redis.mall
- zookeeper.mall
- kafka.mall
depends_on:
- mysql.mall
- redis.mall
- zookeeper.mall
- kafka.mall
ports:
- "80:80"
- "443:443"
privileged: true
command: ["/opt/run.sh"]
[root@master gpmall-ok]# docker-compose up
# 基于Docker容器的情感分析
# 【题目1】构建 sa-logic 镜像
- 编写yum文件
[root@master ~]# cd sentiment-analyzer/
[root@master sentiment-analyzer]# vi local.repo
[sa]
name=sa
baseurl=file:///opt/sa-repo
gpgcheck=0
enabled=1
- 编写构建sa-logic镜像的Dockerfile文件
[root@master sentiment-analyzer]# cat Dockerfile-logic
FROM centos:centos7.5.1804
MAINTAINER Guo
WORKDIR /root
COPY sa-repo /opt/sa-repo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY sa-logic/app.py /root/app.py
COPY sa-logic/requirements.txt /root/requirements.txt
ADD sa-logic/python-packages.tar.gz /root
RUN yum -y install python3
RUN pip3 install --user --find-links=python-packages -r /root/requirements.txt
EXPOSE 5000
CMD ["python3","app.py"]
[root@master sentiment-analyzer]# docker build -t sa-logic:v1.0 -f Dockerfile-logic .
# 【题目2】构建 sa-webapp 镜像
- 编写构建sa-webapp镜像的Dockerfile文件
[root@master sentiment-analyzer]# cat Dockerfile-webapp
FROM centos:centos7.5.1804
MAINTAINER Guo
WORKDIR /root
COPY sa-repo /opt/sa-repo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
ADD sa-webapp/go-packages.tar.gz /root
RUN yum -y install golang
RUN go build -o webapp .
EXPOSE 8080
CMD ["/root/webapp"]
[root@master sentiment-analyzer]# docker build -t sa-webapp:v1.0 -f Dockerfile-webapp .
# 【题目3】构建 sa-frontend 镜像
- 编写构建sa-frontend镜像的Dockerfile文件
[root@master sentiment-analyzer]# cat Dockerfile-frontend
FROM centos:centos7.5.1804
MAINTAINER Guo
WORKDIR /root
COPY sa-repo /opt/sa-repo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
ADD sa-frontend/sa-frontend.tar.gz /root
ENV VUE_APP_API_HOST=http://192.168.200.10:9002
RUN yum -y install nodejs nginx
RUN npm run build && rm -rf /usr/share/nginx/html/* && cp -rf dist/* /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
[root@master sentiment-analyzer]# docker build -t sa-frontend:v1.0 -f Dockerfile-frontend .
# 【题目4】编排部署 sentiment-analyzer
- 编写 docker-compose.yaml 文件
[root@master sentiment-analyzer]# cat docker-compose.yaml
version: '3'
services:
sa-logic:
container_name: sa-logic
image: sa-logic:v1.0
ports:
- "9001:5000"
sa-webapp:
container_name: sa-webapp
image: sa-webapp:v1.0
ports:
- "9002:8080"
depends_on:
- sa-logic
environment:
- API_HOST=http://sa-logic:5000
sa-frontend:
container_name: sa-frontend
image: sa-frontend:v1.0
ports:
- "9003:80"
depends_on:
- sa-webapp
- 启动服务
[root@master sentiment-analyzer]# docker-compose up -d
Creating network "sentiment-analyzer_default" with the default driver
Creating sa-logic ... done
Creating sa-webapp ... done
Creating sa-frontend ... done
[root@master sentiment-analyzer]# docker-compose ps
Name Command State Ports
-------------------------------------------------------------------
sa-frontend nginx -g daemon off; Up 0.0.0.0:9003->80/tcp
sa-logic python3 app.py Up 0.0.0.0:9001->5000/tcp
sa-webapp /root/webapp Up 0.0.0.0:9002->8080/tcp
# 容器化编排mall-swarm
云梦公司开发了一套基于SpringBoot+MyBatis微服务架构的ChinaSkillsMall电商系统, 并实现全容器化部署,ChinaSkillsMall 电商应用系统架构如图 1 所示,系统说明如表 2 所示。
将 MariaDB 数据库组件、Redis 消息组件、RabbitMQ 消息组件、Nacos-Registry 注册 中心服务组件和前端 Nginx 组件按照要求进行容器化。(所需要的软件包 mall-swarm.tar.gz 在 http服务中)
# 【题目1】容器化部署MariaDB
在 master 节 点 上 编 写 /root/mall-swarm/Dockerfile-mariadb文件构建chinaskillmall-mariadb:v1.1镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)安装并初始化 mariadb,密码:root;
(4)设置数据库编码为 UTF-8;
(5)开放端口:3306
(6)设置 mariadb 开机自启
[root@master ~]# tar -zxvf mall-swarm.tar.gz
[root@master ~]# cd mall-swarm/
[root@master mall-swarm]# ll
total 303292
drwxr-xr-x 2 root root 127 Apr 23 2021 images
-r--r--r-- 1 root root 183246769 Apr 23 2021 jdk-8u121-linux-x64.tar.gz
-rw-r--r-- 1 root root 73 Nov 23 08:47 local.repo
-rw-r--r-- 1 root root 68323707 Apr 23 2021 mall-admin-web.tar.gz
drwxr-xr-x 4 root root 38 Apr 23 2021 mall-repo
-rw-r--r-- 1 root root 220900 Apr 23 2021 mall.sql
-rw-r--r-- 1 root root 44698307 Apr 23 2021 nacos-server-1.1.0.tar.gz
-rw-r--r-- 1 root root 896 Apr 23 2021 nginx.conf
-rw-r--r-- 1 root root 14065831 Apr 3 2019 node-v6.17.1-linux-x64.tar.gz
配置yum源
[root@master mall-swarm]# cat local.repo
[mall]
name=mall
baseurl=file:///opt/mall-repo
gpgcheck=0
enabled=1
[root@master mall-swarm]# cat run.sh
#!/bin/bash
mysql_install_db --user=root
mysqld_safe --user=root &
sleep 5
mysqladmin -uroot password root
mysql -uroot -proot -e "grant all on *.* to 'reader'@'%' identified by '123456';"
mysql -uroot -proot -e "create database mall;use mall;source /opt/mall.sql;"
[root@master mall-swarm]# cat Dockerfile-mysql
FROM centos:centos7.5.1804
MAINTAINER Guo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY mall-repo /opt/mall-repo
COPY mall.sql /opt/
COPY run.sh /opt/
ENV LC_ALL en_US.UTF-8
RUN yum install -y mariadb mariadb-server && bash /opt/run.sh
EXPOSE 3306
CMD ["mysqld_safe","--user=root"]
[root@master mall-swarm]# docker build -t mall-mysql:v1.0 -f Dockerfile-mysql .
# 【题目2】容器化部署Redis
在 master 节点上编写/root/mall-swarm/Dockerfile-redis 文件构建 chinaskillmall-redis:v1.1 镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)安装 redis 服务;
(4)修改配置文件中的 bind 127.0.0.1 为 bind 0.0.0.0;
(5)设置 redis 免密,并关闭保护模式;
(6)开放端口:6379;
(7)设置服务开机自启。
[root@master mall-swarm]# cat Dockerfile-redis
FROM centos:centos7.5.1804
MAINTAINER Guo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY mall-repo /opt/mall-repo
RUN yum install -y redis && \
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/redis.conf && \
sed -i 's/protected-mode yes/protected-mode no/g' /etc/redis.conf
EXPOSE 6379
CMD ["/usr/bin/redis-server","/etc/redis.conf"]
[root@master mall-swarm]# docker build -t mall-redis:v1.0 -f Dockerfile-redis .
# 【题目3】容器化部署rabbitmq
在 master 节点上编写/root/mall-swarm/Dockerfile-rabbit 文件构建 chinaskillmall-rabbit:v1.1 镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)安装 rabbitmq 服务;
(4)创建rabbitmq的mall用户给administrator权限
(5)开启rabbitmq的图形化界面
(6)开放端口:5672 15672;
(7)设置服务开机自启。
[root@master mall-swarm]# cat rabbit-user.sh
#!/bin/bash
/usr/lib/rabbitmq/bin/rabbitmq-server restart
sleep 8
/usr/lib/rabbitmq/bin/rabbitmqctl add_vhost mall
/usr/lib/rabbitmq/bin/rabbitmqctl add_user mall mall
/usr/lib/rabbitmq/bin/rabbitmqctl set_user_tags mall administrator
/usr/lib/rabbitmq/bin/rabbitmqctl set_permissions -p mall mall '.*' '.*' '.*'
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management
/usr/lib/rabbitmq/bin/rabbitmq-server restart
[root@master mall-swarm]# cat Dockerfile-rabbit
FROM centos:centos7.5.1804
MAINTAINER Guo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY rabbit-user.sh /opt/rabbit-user.sh
COPY mall-repo /opt/mall-repo
RUN yum -y install rabbitmq-server
EXPOSE 5672 15672
CMD ["/bin/bash","/opt/rabbit-user.sh"]
[root@master mall-swarm]# docker build -t mall-rabbitmq:v1.0 -f Dockerfile-rabbitmq .
# 【题目4】容器化部署Nacos-Registry
在 master 节 点 上 编 写 /root/mall-swarm/Dockerfile-nacos 文 件 构 建 chinaskillmall-nacos:v1.1 镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)安装 jdk 工具和 nacos-server 工具;
(4)设置 nacos 服务开机自启。
[root@master mall-swarm]# cat start.sh
#!/bin/bash
/usr/local/bin/nacos/bin/startup.sh -m standalone
tail -f /usr/local/bin/nacos/logs/start.out
[root@master mall-swarm]# car Dockerfile-nacos
-bash: car: command not found
[root@master mall-swarm]# cat Dockerfile-nacos
FROM centos:centos7.5.1804
MAINTAINER Guo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY mall-repo /opt/mall-repo
COPY start.sh /opt/
ADD jdk-8u121-linux-x64.tar.gz /usr/local/bin/
ADD nacos-server-1.1.0.tar.gz /usr/local/bin/
ENV JAVA_HOME /usr/local/bin/jdk1.8.0_121
EXPOSE 8848
CMD ["/bin/bash","/opt/start.sh"]
[root@master mall-swarm]# docker build -t mall-nacos:v1.0 -f Dockerfile-nacos .
# 【题目5】容器化部署前端服务
在 master节点上安装node工具 ,对mall-admin-web项目进行打包 , 然 后 编 写 /root/mall-swarm/Dockerfile-nginx 文件构建 chinaskillmall-nginx:v1.1 镜像,具体要求如下:
(1)基础镜像:centos:centos7.5.1804;
(2)作者:Chinaskill;
(3)安装 nginx 服务;
(4)将 mall-admin-web 项目打包后的文件拷贝到/usr/share/nginx/html 目录下;
(5)设置 nginx 服务开机自启。
[root@master mall-swarm]# tar -zxvf mall-admin-web.tar.gz
[root@master mall-swarm]# cd mall-admin-web/
[root@master mall-admin-web]# vi config/prod.env.js
'use strict'
module.exports = {
NODE_ENV: '"production"',
BASE_API: '"http://172.25.253.11:8201/mall-admin"' #修改成自己的IP
}
[root@master mall-admin-web]# cd ../
[root@master mall-swarm]# tar zxvf node-v6.17.1-linux-x64.tar.gz
[root@master mall-swarm]# mv node-v6.17.1-linux-x64 /usr/local/node
[root@master mall-swarm]# vi /etc/profile
···
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH
[root@master mall-swarm]# cd mall-admin-web/
[root@master mall-admin-web]# npm run build
> mall-admin-web@1.0.0 build /root/mall-swarm/mall-admin-web
> node build/build.js
⠴ building for production...
[root@master mall-admin-web]# mv dist/ ../
[root@master mall-admin-web]# cd ..
[root@master mall-swarm]# cat Dockerfile-nginx
FROM centos:centos7.5.1804
MAINTAINER Guo
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY mall-repo /opt/mall-repo
RUN yum install -y nginx
COPY dist/ /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
# 【题目6】编排部署ChinaSkillsMall商城
在 master 节点上编写/root/mall-swarm/docker-compose.yaml 文件,具体要求如下:
(1)容器 1 名称:chinaskillmall-admin;镜像:mall/mall-admin:1.0-SNAPSHOT;端口 映射:8080:8080;
(2)容器 2 名称: chinaskillmall-auth;镜像:mall/mall-auth:1.0-SNAPSHOT;端口映 射:8401:8401;
(3)容器 3 名称:chinaskillmall-gateway;镜像:mall/mall-gateway:1.0-SNAPSHOT; 端口映射:8201:8201;
(4)容器 4 名称:chinaskillmall-mysql;镜像:chinaskillmall-mariadb:v1.1;端口映射: 3306:3306;
(5)容器 5 名称:chinaskillmall-nacos;镜像:chinaskillmall-nacos:v1.1;端口映射: 8848:8848;
(6)容器 6 名称:chinaskillmall-nginx;镜像:chinaskillmall-nginx:v1.1;端口映射: 8888:80;
(7)容器 7 名称:chinaskillmall-redis;镜像:chinaskillmall-redis:v1.1;端口映射: 6379:6379。
(7)容器 8 名称:chinaskillmall-rabbit;镜像:chinaskillmall-rabbit:v1.1;端口映射: 5672 15672。
[root@master mall-swarm]# cat docker-compose.yaml
version: "3"
services:
mall-mysql:
image: mall-mysql:v1.0
container_name: mall-mysql
restart: always
ports:
- "13306:3306"
mall-redis:
image: mall-redis:v1.0
container_name: mall-redis
restart: always
ports:
- "16379:16379"
mall-nginx:
image: mall-nginx:v1.0
container_name: mall-nginx
restart: always
ports:
- "8888:80"
mall-rabbit:
image: mall-rabbit:v1.0
container_name: mall-rabbit
ports:
- "5672:5672"
- "15672:15672"
nacos-registry:
image: mall-nacos:v1.0
container_name: nacos-registry
ports:
- "8848:8848"
mall-admin:
image: mall/mall-admin:1.0-SNAPSHOT
container_name: mall-admin
restart: always
ports:
- "8082:8080"
links:
- mall-mysql:db
mall-gateway:
image: mall/mall-gateway:1.0-SNAPSHOT
container_name: mall-gateway
restart: always
ports:
- "8201:8201"
links:
- mall-redis:mall-redis
- nacos-registry:nacos-registry
mall-auth:
image: mall/mall-auth:1.0-SNAPSHOT
container_name: mall-auth
restart: always
ports:
- "8401:8401"
links:
- nacos-registry:nacos-registry