我正在尝试“混合”使用暴露于Internet的Traefik的容器和不使用Traefik的容器,这些容器仅在我的LAN端可用。但是我遇到了一个问题,似乎我无法将未使用Traefik的容器与使用Traefik的容器连接。
version: "3.6"
services:
traefik:
hostname: traefik
image: traefik:latest
container_name: traefik
restart: always
domainname: ${DOMAINNAME}
networks:
- default
- traefik_proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
environment:
- CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
labels:
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.frontend.rule=Host:traefik.${DOMAINNAME}"
# - "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /traefik"
- "traefik.port=8080"
- "traefik.docker.network=traefik_proxy"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${USERDIR}/docker/traefik:/etc/traefik
- ${USERDIR}/docker/shared:/shared
mariadb:
image: "linuxserver/mariadb"
container_name: "mariadb"
hostname: mariadb
volumes:
- ${USERDIR}/docker/mariadb:/config
ports:
- target: 3306
published: 3306
protocol: tcp
mode: host
restart: always
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- PUID=${PUID}
- PGID=${PGID}
- TZ=${TZ}
nextcloud:
container_name: nextcloud
depends_on:
- traefik
- mariadb
- redis
restart: always
image: linuxserver/nextcloud
volumes:
- ${USERDIR}/docker/nextcloud:/config
- ${USERDIR}/shared_data:/data # Path to data you want to share/sync
- ${USERDIR}/docker/shared:/shared
# ports:
# - "XXXX:443"
environment:
- PUID=${PUID}
- PGID=${PGID}
networks:
- traefik_proxy
- default
labels:
- "traefik.enable=true"
- "traefik.backend=nextcloud"
- "traefik.frontend.rule=Host:nextcloud.${DOMAINNAME}"
- "traefik.port=443"
- "traefik.protocol=https"
- "traefik.docker.network=traefik_proxy"
networks:
traefik_proxy:
external:
name: traefik_proxy
default:
driver: bridge
我可以通过nextcloud.example.com到达我的nextcloud容器,也可以到达traefik子域。因此traefik似乎已启动并运行。
如果我执行$ docker-compose ps
,则mariadb已启动
mariadb /init Up 0.0.0.0:3306->3306/tcp
还有nextcloud nextcloud /init Up 443/tcp, 80/tcp
我尝试将网络traefik_proxy添加到mariadb,没有运气,并且尝试将默认网络添加到nextcloud。