简体   繁体   中英

nginx don't replicate on docker swrm

I am trying to use nginx for miscoservices running on docker swarm but nginx don't replicate. I use docker stack deploy -c docker-compose.yml neo. I replicate service profile using docker service scale neo_profile=3.

docker-compose.yml

version: "3"
services:
  frontend:
    build: .
    image: ${REGISTRY-127.0.0.1:5000}/hotel_app_frontend_single_node_memdb
    entrypoint: frontend
    ports:
      - "8080:8080"
    restart: always

  profile:
    build: .
    image: ${REGISTRY-127.0.0.1:5000}/hotel_app_profile_single_node_memdb
    entrypoint: profile
    ports:
      - "8081:8081"
    restart: always

  search:
    build: .
    image: ${REGISTRY-127.0.0.1:5000}/hotel_app_search_single_node_memdb
    entrypoint: search
    ports:
      - "8082:8082"
    restart: always

  geo:
    build: .
    image: ${REGISTRY-127.0.0.1:5000}/hotel_app_geo_single_node_memdb
    entrypoint: geo
    ports:
      - "8083:8083"
    restart: always

  rate:
    build: .
    image: ${REGISTRY-127.0.0.1:5000}/hotel_app_rate_single_node_memdb
    entrypoint: rate
    ports:
      - "8084:8084"
    restart: always

  jaeger:
      image: jaegertracing/all-in-one:latest
      ports:
        - "14269"
        - "5778:5778"
        - "14268:14268"
        - "14267"
        - "16686:16686"
        - "5775:5775/udp"
        - "6831:6831/udp"
        - "6832:6832/udp"
      restart: always

  nginx:
      image: nginx:1.20.0
      ports:
        - "8581:8581"
      volumes:
        - ./nginx.conf:/etc/nginx/nginx.conf:ro

nginx.conf

upstream profile_server {

  server profile:8081;
}

server {
  listen 8581 http2;
  location / {
    grpc_pass grpc://profile_server;
  }
}
    

docker service ls:

ID             NAME           MODE         REPLICAS   IMAGE                                                  PORTS
xzpuq5yg5y93   neo_frontend   replicated   1/1        xxxx/hotel_app_frontend_single_node_memdb:latest   *:8080->8080/tcp
uoygftsgih83   neo_geo        replicated   1/1        xxxx/hotel_app_geo_single_node_memdb:latest        *:8083->8083/tcp
kr8gf6e9jjtm   neo_jaeger     replicated   1/1        jaegertracing/all-in-one:latest                        *:5778->5778/tcp, *:14268->14268/tcp, *:16686->16686/tcp, *:30002->14269/tcp, *:30003->14267/tcp, *:5775->5775/udp, *:6831-6832->6831-6832/udp
uiswjuc9gh0e   neo_nginx      replicated   0/1        nginx:1.20.0                                           *:8581->8581/tcp
hgf13q8iu0ub   neo_profile    replicated   3/3        xxxx/hotel_app_profile_single_node_memdb:latest    *:8081->8081/tcp
78jt97fcb55q   neo_rate       replicated   1/1        xxxx/hotel_app_rate_single_node_memdb:latest       *:8084->8084/tcp
fnguxpzn4pfr   neo_search     replicated   1/1        xxxx/hotel_app_search_single_node_memdb:latest     *:8082->8082/tcp

For some reason nginx did not replicate.

Deploy your nginx config as a docker config:

configs:
  nginx-conf-1:
    file: ./configs/nginx.conf

services:
  nginx:
    configs:
    - source: nginx-conf-1
      target: /etc/nginx/nginx.conf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM