原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
原文链接地址:『高级篇』docker之DockerSwarm调整微服务及服务配置(29)10余年的南平网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。网络营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整南平建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“南平网站设计”,“南平网站推广”以来,每个客户项目都认真落实执行。
上次已经搭建好了swarm的集群环境,server01,server02,server03三台虚拟机,每一台的manager节点也是work节点,首先我们考虑的问题是服务的发现,从微服务的角度考虑,我们有得服务是为了其他服务使用的,如message service,user service,对于swarm上,有的需要暴露端口给其他服务使用,有的是直接通过服务的名称就可以访问的,改造模式,改造代码,然后上传到镜像仓库。最后配置一个docker stack 把他们的关系编写出来,一条命令搞定了。源码:https://github.com/limingios/msA-docker swarm分支
sh
#!/usr/bin/env bash
source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/course-dubbo-service:latest .
docker push zhugeaming/course-dubbo-service:latest
>Dockerfile
``` bash
FROM java:openjdk-8
MAINTAINER liming www.idig8.com
COPY target/course-dubbo-service-1.0-SNAPSHOT.jar /course-dubbo-service.jar
ENTRYPOINT ["java","-jar","/course-dubbo-service.jar"]
sh
#!/usr/bin/env bash
source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/course-edge-service:latest .
docker push zhugeaming/course-edge-service:latest
>Dockerfile
``` bash
FROM java:openjdk-8
MAINTAINER liming www.idig8.com
COPY target/course-edge-service-1.0-SNAPSHOT.jar /course-edge-service.jar
ENTRYPOINT ["java","-jar","/course-edge-service.jar"]
sh
#!/usr/bin/env bash
source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/gataway-zuul:latest .
docker push zhugeaming/gataway-zuul:latest
>Dockfile
``` bash
FROM java:openjdk-8
MAINTAINER liming www.idig8.com
COPY target/gataway-zuul-1.0-SNAPSHOT.jar /gataway-zuul.jar
ENTRYPOINT ["java","-jar","/gataway-zuul.jar"]
sh
#!/usr/bin/env bash source ~/.bash_profile mvn package docker build -f ./Dockerfile-hub -t zhugeaming/user-edge-service:latest . docker push zhugeaming/user-edge-service:latest
Dockerfile
#!/usr/bin/env bash source ~/.bash_profile mvn package docker build -f ./Dockerfile-hub -t zhugeaming/user-edge-service:latest . docker push zhugeaming/user-edge-service:latest
sh
#!/usr/bin/env bash source ~/.bash_profile mvn package docker build -f ./Dockerfile-hub -t zhugeaming/user-thrift-service:latest . docker push zhugeaming/user-thrift-service:latest
Dockerfile
FROM java:openjdk-8 MAINTAINER liming www.idig8.com
COPY target/user-thrift-service-1.0-SNAPSHOT.jar /user-thrift-service.jar
ENTRYPOINT ["java","-jar","/user-thrift-service.jar"]
* 编写yml文件 使用docker stack 进行批量生成
``` yml
version: "3.4"
services:
message-thrift-python-service:
image: zhugeaming/message-thrift-python-service:latest
deploy:
endpoint_mode: DNSrr
resources:
limits:
cpus: "0.2"
memory: "128M"
user-thrift-service:
image: zhugeaming/user-thrift-service:latest
deploy:
endpoint_mode: dnsrr
resources:
limits:
cpus: "0.2"
memory: "512M"
user-edge-service:
image: zhugeaming/user-edge-service:latest
deploy:
endpoint_mode: vip
resources:
limits:
cpus: "0.2"
memory: "512M"
ports:
- "8082:8082"
depends_on:
- user-thrift-service
- message-thrift-python-service
course-dubbo-service:
image: zhugeaming/user-edge-service:latest
deploy:
endpoint_mode: dnsrr
resources:
limits:
cpus: "0.2"
memory: "512M"
depends_on:
- user-thrift-service
course-edge-service:
image: zhugeaming/course-edge-service:latest
deploy:
endpoint_mode: vip
resources:
limits:
cpus: "0.2"
memory: "512M"
ports:
- "8081:8081"
depends_on:
- user-edge-service
gateway-zuul:
image: zhugeaming/gataway-zuul:latest
deploy:
endpoint_mode: vip
resources:
limits:
cpus: "0.2"
memory: "512M"
ports:
- "8080:8080"
depends_on:
- user-edge-service
- course-edge-service
networks:
default:
external:
name: idig8-overlay
docker stack 创建,因为机器内存太小,我还是使用的外网,下载镜像有点慢。
docker stack deploy -c ms-service.yml ms
docker stack services ms
PS:创建成功,下一步就是调试微服务。