在 docker-compose 中使用现有网络:服务“网络”必须是映射而不是数组

在 docker-compose 中使用现有网络:服务“网络”必须是映射而不是数组

我想要使​​用现有的网络“nextcloudpi”:

$ sudo docker network ls
NETWORK ID     NAME                               DRIVER    SCOPE
bc60ac79af99   bridge                             bridge    local
e374ccc22ff4   host                               host      local
6822ac7b54c6   ncp_reverse_proxy_bc_nextcloudpi   bridge    local
dc749eca4598   ncp_reverse_proxy_nextcloudpi      bridge    local
6a83b3f6e623   nextcloudpi                        bridge    local
eeb4fc6c4f16   none                               null      local
79949d81c193   overleaf_default                   bridge    local

我收到错误:

在文件'./docker-compose.yml'中,服务'networks'必须是映射而不是数组

version: '2.2'


networks:
  nextcloudpi:
    external: true


services:
    sharelatex:
        restart: always
        # Server Pro users:
        # image: quay.io/sharelatex/sharelatex-pro
        image: sharelatex/sharelatex
        container_name: sharelatex
        depends_on:
            mongo:
                condition: service_healthy
            redis:
                condition: service_started
        ports:
            - 83:80
        links:
            - mongo
            - redis
        networks:
           - nextcloudpi

答案1

该文件按预期运行:

version: '2.2'
  

services:
    sharelatex:
        restart: always
        # Server Pro users:
        # image: quay.io/sharelatex/sharelatex-pro
        image: sharelatex/sharelatex
        container_name: sharelatex
        depends_on:
            mongo:
                condition: service_healthy
            redis:
                condition: service_started
        ports:
            - 83:80
        links:
            - mongo
            - redis
        

networks:
  default:
    name: nextcloudpi
    external: true

相关内容