Drone

Drone/cli exec --network switch does nothing

Maybe I’m holding it wrong, but here’s what I did:

.drone.yml:

kind: pipeline
name: default

steps:
  - name: foo
    image: alpine
    command:
      - sleep
      - 999999

then I ran

$ docker network create foo
$ docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)":/"$(pwd)" -w /"$(pwd)" \
drone/cli:1-alpine exec \
		--network foo \
		.drone.yml

I would have expected the container to be inside the “foo” network, but it isn’t.

So, this almost works if one also sets network_mode in the step definition,
either to bridge or to the network’s name:

steps:
  - name: foo
    image: alpine
    network_mode: bridge
    command:
      - sleep
      - 999999

And then let’s call the network bar because otherwise that gets confusing:

$ docker network create bar
$ docker run -it --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$(pwd)":/"$(pwd)" -w /"$(pwd)" \
    drone/cli:1-alpine exec \
            --trusted \
            --network bar \
            .drone.yml

Then, the container is in bar, but the container’s alias is wrong - it’s
using the network’s name, not the container name:

I’m pretty sure that should be Aliases: []string{step.Metadata.Name} instead.

But this is all abandoned/archived, so I guess this stays broken until someone rewrites drone/cli exec in terms of the drone-runners.