Multiple drone_default networks created with services

Docker version 1.13.1, build 092cba3

Im getting multiple drone_default networks created, and so my build step is not always in the same network as (all) my services (I’ve seen it connect with postgres sometimes, services_1 seems to always be unavailable).

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                     NAMES
ff9718395655        drone/drone:0.7     "/drone agent"      4 days ago          Up 4 days           80/tcp, 443/tcp, 8000/tcp                 drone_agent_1
302ea0ef7cd7        drone/drone:0.7     "/drone server"     4 days ago          Up 4 days           80/tcp, 443/tcp, 0.0.0.0:8000->8000/tcp   drone_server_1
$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
84080a03864a        bridge              bridge              local
841693898a66        drone_default       bridge              local
1be2675282ec        host                host                local
0faacedf1346        none                null                local

Services config:

services:
  postgres:
    image: postgres
    environment:
      - POSTGRES_USER=dbuser
      - POSTGRES_DB=dbname

  elastic:
    image: elasticsearch:5.1

Then run drone exec, I put a sleep 200 in commands so there is time to investigate networking.

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                     NAMES
7d9eea91e991        node:6.10           "/bin/sh -c 'echo ..."   10 seconds ago      Up 9 seconds                                                  drone_step_0
c964d2a96242        postgres:latest     "docker-entrypoint..."   11 seconds ago      Up 10 seconds       5432/tcp                                  drone_services_0
45df59380708        elasticsearch:5.1   "/docker-entrypoin..."   11 seconds ago      Up 10 seconds       9200/tcp, 9300/tcp                        drone_services_1
ff9718395655        drone/drone:0.7     "/drone agent"           4 days ago          Up 4 days           80/tcp, 443/tcp, 8000/tcp                 drone_agent_1
302ea0ef7cd7        drone/drone:0.7     "/drone server"          4 days ago          Up 4 days           80/tcp, 443/tcp, 0.0.0.0:8000->8000/tcp   drone_server_1
$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
84080a03864a        bridge              bridge              local
841693898a66        drone_default       bridge              local
c2e2b41fc4aa        drone_default       bridge              local
1be2675282ec        host                host                local
0faacedf1346        none                null                local
$ docker inspect drone_step_0 --format "{{ json .NetworkSettings.Networks.drone_default.NetworkID }}"
"c2e2b41fc4aa0cc81c93063c5d918dee1cb1a5e01a3fb756a5f5da2f568da1e8"
$ docker inspect drone_services_0 --format "{{ json .NetworkSettings.Networks.drone_default.NetworkID }}"
"c2e2b41fc4aa0cc81c93063c5d918dee1cb1a5e01a3fb756a5f5da2f568da1e8"
$ docker inspect drone_services_1 --format "{{ json .NetworkSettings.Networks.drone_default.NetworkID }}"
"841693898a662ce75c6ec86e40315c140bd1e29f7f93f35fdabb9dd4a0fbdd11"

It was because drone_default already existed from my docker-compose setup for drone server/agent. Then these naming conflicts arise.

Solution is to use another network name for compose, or run drone exec --prefix=foo

you can use “docker network rm 841693898a66 c2e2b41fc4aa” to remove two drone_default bridge in your case too. I am not sure how this happened but it does happen to me once in a while.

docker network prune when this happens.

Newer versions of the Drone CLI sends a warning as well when networks are ambigious.