问题描述
我有如下所示的 docker-compose 文件。我运行的时候,factory、graphql、pgadmin这三个服务不一致。有时一个正在运行,有时两个,有时没有。如果我删除 graphql 和 pgadmin,工厂总是有效。
我尝试过明确添加端口并删除它们,但似乎没有任何区别。我应该明确声明端口吗?
version: "3.3"
services:
traefik:
image: "traefik:v2.4"
container_name: "traefik"
command:
- "--log.level=ERROR"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=web"
- "--entrypoints.web.address=:80"
depends_on:
- factory
- graphql
- pgadmin
- v3joegattnet
labels:
- "traefik.http.routers.traefik.entrypoints=web"
- "traefik.http.routers.api.rule=Host(`traefik.localhost`)"
- "traefik.http.routers.api.service=api@internal"
- "traefik.http.routers.api.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=admin:${TRAEFIK_PASSWORD}"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- web
factory:
container_name: factory.joegatt.net
build:
context: ./joegatt.net-factory
volumes:
- ./tmp/npm:/root/.npm:z
- ./joegatt.net-factory/src:/usr/src/app/src:z
labels:
- "traefik.enable=true"
- "traefik.http.routers.factory.rule=Host(`factory.localhost`,`joegattorg.localhost`)"
- "traefik.http.routers.factory.entrypoints=web"
command: node ./dist/index.js
environment:
- NODE_ENV=production
networks:
- web
restart: always
graphql:
container_name: graphql
image: graphile/postgraphile
environment:
DATABASE_URL: postgres://${JOEGATTNET_USER}:${JOEGATTNET_PASSWORD}@postgres:5432/${JOEGATTNET_DB}
PORT: 5432
depends_on:
- postgres
labels:
- "traefik.enable=true"
- "traefik.http.routers.graphql.rule=Host(`graphql.localhost`) && (PathPrefix(`/graphiql`) || PathPrefix(`/graphql`))"
- "traefik.http.routers.factory.entrypoints=web"
- "traefik.port=5000"
networks:
- psql-pgql
- web
command:
[
"-w","--cors","-c","postgres://${JOEGATTNET_USER}:${JOEGATTNET_PASSWORD}@postgres:5432/${JOEGATTNET_DB}","-s","api","--extended-errors","hint,detail,errcode","--jwt-secret",$JWT_SECRET,"--token","api.jwt_token","--default-role","unregistered"
]
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4:latest
depends_on:
- postgres
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL:-pgadmin4@pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD:-admin}
networks:
- postgres
- web
labels:
- "traefik.enable=true"
- "traefik.http.routers.pgadmin.rule=Host(`pgadmin.localhost`) && (PathPrefix(`/pgadmin4`))"
- "traefik.http.routers.pgadmin.entrypoints=web"
- "traefik.port=5050"
restart: unless-stopped
postgres:
container_name: postgres
restart: always
image: postgres:10.4-alpine
build:
context: ./joegatt.net-db
volumes:
- ./joegatt.net-db/init:/docker-entrypoint-initdb.d
environment:
POSTGRES_USER: ${JOEGATTNET_USER}
POSTGRES_PASSWORD: ${JOEGATTNET_PASSWORD}
POSTGRES_DB: ${JOEGATTNET_DB}
expose:
- 5432
ports:
- 5432
networks:
- psql-pgql
- postgres
v3joegattnet:
container_name: v3.joegatt.net
build:
context: ./joegatt.net-v3-html
volumes:
- ./joegatt.net-v3-html:/usr/share/Nginx/html
labels:
- "traefik.enable=true"
- "traefik.http.routers.v3joegattnet.rule=Host(`v3joegattnet.localhost`,`joegattnet.localhost`)"
- "traefik.http.routers.v3joegattnet.entrypoints=web"
networks:
- web
networks:
psql-pgql:
postgres:
driver: bridge
web:
driver: bridge
volumes:
postgres:
pgadmin:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)