Cannot deploy a stack with multiple external networks
Before you start please confirm the following.
- Yes, I've searched similar issues on GitHub.
- Yes, I've checked whether this issue is covered in the Portainer documentation or knowledge base.
Problem Description
This has been an ongoing issue for me. For some odd reason that I could not figure out, portainer cannot deploy stacks with two attachable external networks defined in the compose. Both networks are available and there are no conflicts. I saw that this issue has been brought up before and closed in https://github.com/portainer/portainer/issues/1491 but it appears to come back at least for me.
This is an on/off issue that I could not replicate exactly why this happens since sometimes it works and sometimes it does not. Below is my example compose file.
name: databases
x-common-labels: &common-labels
com.centurylinklabs.watchtower.enable: "true"
x-cert-label: &cert-label
server.custom.cert: "true"
x-common: &common
labels: *common-labels
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
networks:
- databases_network
- downloaders_network
x-common-env: &common-env
TZ: ${TZ}
services:
adminer:
<<: *common
image: adminer:latest
user: "${ADMINER_PUID}:${DATABASES_PGID}"
container_name: adminer
healthcheck:
test: |
curl -ILkfs --max-time 3 http://localhost:8080 > /dev/null \
|| exit 1
start_period: 10s
interval: 30s
timeout: 20s
retries: 3
environment:
# ADMINER_PLUGINS: login-servers #frames
ADMINER_DESIGN: rmsoft_blue
<<: *common-env
volumes:
- /volume1/docker/databases/adminer/plugins-enabled:/var/www/html/plugins-enabled
ports:
- 8669:8080
networks:
databases_network:
external: true
downloaders_network:
external: trueExpected Behavior
it should be able to deploy and connect to the defined networks.
Actual Behavior
As soon as I try to deploy it, errors it out. Error:
Failure
Failed to deploy a stack: compose up operation failed: Error response from daemon: Container cannot be connected to network endpoints: databases_network, downloaders_networkSteps to Reproduce
- Create two external attachable networks from the portainer UI
- Try to deploy a similar compose with the above compose
Portainer logs or screenshots
Portainer version
2.31.3
Portainer Edition
Business Edition (BE/EE) with Home & Student license
Platform and Version
Docker 24.0.2
OS and Architecture
DSM 7.2.2
Browser
Brave
What command did you use to deploy Portainer?
name: portainer
x-common-labels: &common-labels
com.centurylinklabs.watchtower.enable: "false"
x-cert-label: &cert-label
server.custom.cert: "true"
x-common: &common
labels: *common-labels
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
networks:
- portainer_network
x-common-env: &common-env
TZ: ${TZ}
x-ssl-cert: &ssl-cert ${HOST_SSL_CERT_PATH}:${CONTAINER_SSL_CERT_PATH}:ro
x-ssl-key: &ssl-key ${HOST_PRIVATE_KEY_PATH}:${CONTAINER_PRIVATE_KEY_PATH}:ro
services:
portainer:
<<: *common
image: portainer/portainer-ee:sts
container_name: portainer
labels:
<<: [*common-labels, *cert-label]
depends_on:
- portainer-agent
command: >
--sslcert ${CONTAINER_SSL_CERT_PATH}
--sslkey ${CONTAINER_PRIVATE_KEY_PATH}
-H tcp://portainer-agent:9001
--tlsskipverify
environment:
<<: *common-env
volumes:
- portainer_data:/data
- /etc/localtime:/etc/localtime:ro
- *ssl-cert
- *ssl-key
ports:
- 8000:8000
- 9443:9443
portainer-agent:
<<: *common
image: portainer/agent:latest
container_name: portainer-agent
environment:
<<: *common-env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
- /:/host
networks:
portainer_network:
external: true
volumes:
portainer_data:
name: portainer_dataAdditional Information
No response
Source: portainer/portainer