Docker compose 如何将graphiql和pgadmin连接到traefik?
我有docker compose文件,如下所示。当我运行它时,称为factory、graphql和pgadmin的三个服务是不一致的。有时一个在跑,有时两个,有时一个也没有。如果我删除graphql和pgadmin,则factory始终有效 我已经尝试过显式地添加端口并删除它们,但似乎没有什么不同。我应该明确声明端口吗Docker compose 如何将graphiql和pgadmin连接到traefik?,docker-compose,traefik,pgadmin,graphiql,Docker Compose,Traefik,Pgadmin,Graphiql,我有docker compose文件,如下所示。当我运行它时,称为factory、graphql和pgadmin的三个服务是不一致的。有时一个在跑,有时两个,有时一个也没有。如果我删除graphql和pgadmin,则factory始终有效 我已经尝试过显式地添加端口并删除它们,但似乎没有什么不同。我应该明确声明端口吗 version: "3.3" services: traefik: image: "traefik:v2.4" c
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: