FROM openjdk:8
MAINTAINER lhy
LABEL name="springboot-mybatis" version="1.0" author="lhy"
COPY springboot-mybatis-demo-0.0.1-SNAPSHOT.jar springboot-mybatis.jar
CMD ["java","-jar","springboot-mybatis.jar"]
docker build -t sbm-image .
docker network create --subnet=172.24.0.0/24 sbm-net
docker run -d --name sb01 -p 8081:8080 --net=sbm-net --ip 172.24.0.11 sbm-image
http://ipclient:8081/user/query (SpringBoot默认提供的访问接口)
docker run -d --name sb01 -p 8081:8080 --net=pro-net --ip 172.24.0.11 sbm-image
docker run -d --name sb02 -p 8082:8080 --net=pro-net --ip 172.24.0.12 sbm-image
docker run -d --name sb03 -p 8083:8080 --net=pro-net --ip 172.24.0.13 sbm-image
docker pull nginx
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
location / {
proxy_pass http://balance;
}
}
upstream balance{
server 172.55.0.11:8080; #这里填写多个SpringBoot的网段IP
server 172.55.0.22:8080;
}
include /etc/nginx/conf.d/*.conf;
}
docker run -d --name my-nginx -p 80:80 -v /tmp/nginx/nginx.conf:/etc/nginx/nginx.conf --network=pxc-net --ip 172.24.0.10 nginx
http://39.108.153.252/user/query