I have two machines, In A, I crate the overlay network :
docker network create --driver overlay --attachable --subnet 172.40.0.0/16 docker3
In other machine,
I want use it in the docker-compose.yml
networks:
docker3:
external:
name: docker3
and then I use command
docker-compose up -d
the result is
ERROR: Network docker3 declared as external, but could not be found. Please create the network manually using docker network create docker3 and try again.
but I can use it in machines A, and use docker run -d --net=docker3
in machines B
Docker version 1.13.1
docker-compose version 1.11.2
What does it say if you run docker network ls
against machine B?
@shin-
Thank you for your replay, you reminded me, I do a test:
My docker-compose.yml has:
...
networks:
docker3:
external:
name: docker3
...
1.In machine A, I create network
docker network create --driver overlay --attachable --subnet 172.40.0.0/16 docker3
docker network ls
in machine A NETWORK ID NAME DRIVER SCOPE
3c63ef8fb2d8 bridge bridge local
p98mtqa3pda3 docker-net overlay swarm
6ec0b6c08fc4 docker1 bridge local
wqyryt3okz30 docker3 overlay swarm
b06ac62ccbe0 docker_gwbridge bridge local
a78178d2a4f2 host host local
ck4buzt54gg2 ingress overlay swarm
6b0f380c9576 none null local
3.docker-compose up
in machine A, it's OK
4.docker-compose up
in machine B, it's ERROR
ERROR: Network docker3 declared as external, but could not be found. Please create the network manually using docker network create docker3 and try again.
5.docker network ls
in machine B
NETWORK ID NAME DRIVER SCOPE
dd6950686064 bridge bridge local
7f89eefbf89f docker_gwbridge bridge local
debd0bc5e2c6 host host local
ck4buzt54gg2 ingress overlay swarm
b47ba18b6681 none null local
It's can't find the network docker3
6.docker run -d --name nginx --net=docker3 --ip 172.40.0.11 nginx
it's OK in machine B
7.docker network ls
in machine B
NETWORK ID NAME DRIVER SCOPE
dd6950686064 bridge bridge local
wqyryt3okz30 docker3 overlay swarm
7f89eefbf89f docker_gwbridge bridge local
debd0bc5e2c6 host host local
ck4buzt54gg2 ingress overlay swarm
b47ba18b6681 none null local
It's can find the network docker3
8.docker-compose up
in machine B, it's OK
So, I must use docker run
and then the docker-compose will be OK, otherwise the network can't be found.
+1
Could be related to https://github.com/docker/compose/issues/4399
@shin- are there any news on that? if needed, i could provide some more debug-information. or is there any advice on how to debug this problem by my self?
@cjk87927 have you fixed this problem? i ran into the same issue. starting a single container first works fine. if no other container on the worker node uses the overlay network, docker-compose up fails with the same error message as you posted.
would be very thankful for some help on that!
here is my setup...
both hosts (manager & worker) running debian stretch
docker info
(manager node)
Client:
Version: 17.09.1-ce
API version: 1.32
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:24:16 2017
OS/Arch: linux/amd64
Server:
Version: 17.09.1-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:22:56 2017
OS/Arch: linux/amd64
Experimental: false
docker-compose --version
(manager node)docker-compose version 1.18.0-rc2, build 189468b
docker info
(worker node)Client:
Version: 17.09.1-ce
API version: 1.32
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:24:16 2017
OS/Arch: linux/amd64
Server:
Version: 17.09.1-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:22:56 2017
OS/Arch: linux/amd64
Experimental: false
docker-compose --version
(worker node)docker-compose version 1.18.0-rc2, build 189468b
$ docker network create -d overlay --subnet 10.10.10.0/24 --attachable docker_test
docker network ls
(manager node)NETWORK ID NAME DRIVER SCOPE
556dce9ba5fc bridge bridge local
yddwfbe4ohwv docker_test overlay swarm
dd8dfb90eb80 docker_gwbridge bridge local
2808636b8a84 host host local
vdnu6plp2m1k ingress overlay swarm
7922223a1e5f none null local
docker-compose.yml
version: "3"
services:
mysql_worker:
image: mysql:5.7
networks:
- my_test
environment:
MYSQL_ROOT_PASSWORD: 12345678
MYSQL_DATABASE: beer
MYSQL_USER: beer-master
MYSQL_PASSWORD: 12345678
networks:
my_test:
external:
name: docker_test
For me the problem persists in version: 1.21.0-rc1
Starting a dummy container (docker run -itd --name shell --net foo alpine /bin/sh), which connects to the overlay network, makes the overlay network available on the worker node. Then docker-compose can attach containers to the overlay network too.
with 1.21.2 issue still present
Same problem here with 1.21.2
This fix https://github.com/docker/compose/commit/1e9a66c75b10ca2a873c44f8dc972d4b570d8f91 involves a double check that the network is declared as external
AND also declared as overlay
in the compose, am I correct?
If I declare my network this way:
networks:
prod:
external: true
driver: overlay
I am getting:
ERROR: Network prod declared as external but specifies additional attributes (driver).
This is the expected behavior since according to: https://docs.docker.com/compose/compose-file/#external
external cannot be used in conjunction with other network configuration keys (driver, driver_opts, ipam, internal).
So how can we resolve this?
@digger18 Actually, that restriction is relaxed for versions > 2.0 (in the 2.x series) and > 3.3 (in the 3.x series), so it should work if you use a more recent version of the Compose format. We'll need to update the documentation accordingly.
Let me know if that helps.
Created https://github.com/docker/docker.github.io/pull/7624 as a follow-up, and closing this as a result.
Most helpful comment
@shin-
Thank you for your replay, you reminded me, I do a test:
My docker-compose.yml has:
1.In machine A, I create network
docker network create --driver overlay --attachable --subnet 172.40.0.0/16 docker3
docker network ls
in machine A3.
docker-compose up
in machine A, it's OK4.
docker-compose up
in machine B, it's ERRORERROR: Network docker3 declared as external, but could not be found. Please create the network manually using docker network create docker3 and try again.
5.
docker network ls
in machine BIt's can't find the network docker3
6.
docker run -d --name nginx --net=docker3 --ip 172.40.0.11 nginx
it's OK in machine B7.
docker network ls
in machine BIt's can find the network docker3
8.
docker-compose up
in machine B, it's OKSo, I must use
docker run
and then the docker-compose will be OK, otherwise the network can't be found.