用于反向代理和服务的多个 Docker-Compose 文件

用于反向代理和服务的多个 Docker-Compose 文件

我创建了两个 docker-compose 文件,第一个创建了一个 nginx-proxy 和一个 letsencrypt-nginx-proxy-companion。另一个 yaml 文件创建了一个 nextcloud 实例(带有 mariadb)。前两个容器启动时没有错误并且可以正常工作,但在启动第二个 compose 文件后,出现以下警告:

Found orphan containers (test-proxy, test-letsencrypt) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.

这是我的撰写文件:

nginx-测试.yml

version: '3.5' 

services:

  proxy:
    image: jwilder/nginx-proxy:alpine
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    container_name: test-proxy
    networks:
      - testnet
    ports:
      - 80:80
      - 443:443
    volumes:
      - /srv/proxy/conf.d:/etc/nginx/conf.d:rw
      - /srv/proxy/vhost.d:/etc/nginx/vhost.d:rw
      - /srv/proxy/html:/usr/share/nginx/html:rw
      - /srv/proxy/certs:/etc/nginx/certs:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: unless-stopped

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: test-letsencrypt
    depends_on:
      - proxy
    networks:
      - testnet
    volumes:
      - /srv/proxy/certs:/etc/nginx/certs:rw
      - /srv/proxy/vhost.d:/etc/nginx/vhost.d:rw
      - /srv/proxy/html:/usr/share/nginx/html:rw
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: unless-stopped

networks:
  testnet:

nextcloud-test.yml

version: '3.5' 

services:

  db:
    image: mariadb
    container_name: nextcloud-mariadb
    networks:
      - testnet
    volumes:
      - db:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=test
      - MYSQL_PASSWORD=test
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped

  app:
    image: nextcloud:latest
    container_name: nextcloud-test
    networks:
      - testnet
    depends_on:
      - db
    volumes:
      - nextcloud:/var/www/html
      - /srv/nextcloud/config:/var/www/html/config
      - /srv/app/custom_apps:/var/www/html/custom_apps
      - /srv/app/data:/var/www/html/data
      - /srv/app/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - VIRTUAL_HOST=nextcloud.localhost
      - LETSENCRYPT_HOST=nextcloud.localhost
      - [email protected]
    restart: unless-stopped

volumes:
  nextcloud:
  db:

networks:
  testnet:

如果我在一个 yml 文件中启动所有四个容器,则一切都会启动,并且我可以通过 nextcloud.localhost 访问 nextcloud。我应该在 yml 文件中进行哪些更改,以便四个容器可以相互交互?

相关内容