Docker部署

Redis集群

1.创建网卡

[root@test5 ~]# docker network create redis --subnet 172.38.0.0/16

2.通过脚本创建6个redis配置

for port in $(seq 1 6); \

do \

mkdir -p /mydata/redis/node-${port}/conf

touch /mydata/redis/node-${port}/conf/redis.conf

cat << EOF >/mydata/redis/node-${port}/conf/redis.conf

port 6379

bind 0.0.0.0

cluster-enabled yes

cluster-confgi-file nodes.conf

cluster-node-timeout 5000

cluster-announce-ip 172.38.0.1${port}

cluster-announce-port 6379

cluster-announce-bus-port 16379

appendonly yes

EOF

done

3.启动

docker run -p 6371:6379 -p 16371:16379 --name redis-1  -v /mydata/redis/node-1/data:/data  -v /mydata/redis/node-1/conf/redis.conf:/etc/redis.conf  -it  --net redis --ip 172.38.0.11 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf

docker run -p 6372:6379 -p 16372:16379 --name redis-2  -v /mydata/redis/node-2/data:/data  -v /mydata/redis/node-2/conf/redis.conf:/etc/redis.conf  -it  --net redis --ip 172.38.0.12 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf

docker run -p 6373:6379 -p 16373:16379 --name redis-3  -v /mydata/redis/node-3/data:/data  -v /mydata/redis/node-3/conf/redis.conf:/etc/redis.conf  -it  --net redis --ip 172.38.0.13 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf

docker run -p 6374:6379 -p 16374:16379 --name redis-4  -v /mydata/redis/node-4/data:/data  -v /mydata/redis/node-4/conf/redis.conf:/etc/redis.conf  -it  --net redis --ip 172.38.0.14 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf

docker run -p 6375:6379 -p 16375:16379 --name redis-5  -v /mydata/redis/node-5/data:/data  -v /mydata/redis/node-5/conf/redis.conf:/etc/redis.conf  -it --net redis --ip 172.38.0.15 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf

docker run -p 6376:6379 -p 16376:16379 --name redis-6  -v /mydata/redis/node-6/data:/data  -v /mydata/redis/node-6/conf/redis.conf:/etc/redis.conf  -it --net redis --ip 172.38.0.16 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf

SpringBoot打包Docker镜像

1.架构SpringBoot项目

2.打包应用

项目打包成jar包

3.编写dockerfile

FROM java:8

COPY *.jar /app.jar

CMD ["----server----"]

EXPOSE 8080

ENTRYPOINT ["java","-jar","/app.jar"]

4.构建镜像(同一目录)

docker build -t shawlen .

5.发布运行

docker run -d -P --name shawlen01 shawlen


6.测试

http://10.211.55.5:49153/hello

你可能感兴趣的:(Docker部署)