# Drone/cli exec --network switch does nothing

**URL:** <https://drone.discourse.group/t/drone-cli-exec-network-switch-does-nothing/10453>\
**Category:** Drone Bugs\
**Created:** [January 20, 2020, 4:29pm UTC](https://drone.discourse.group/t/drone-cli-exec-network-switch-does-nothing/10453 "2020-01-20T16:29:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwos](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/rwos/32/6157_2.png) [@rwos](https://drone.discourse.group/u/rwos)\
**Post date:** [January 20, 2020, 4:29pm UTC](https://drone.discourse.group/t/drone-cli-exec-network-switch-does-nothing/10453/1 "2020-01-20T16:29:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rwos](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/rwos/32/6157_2.png) [@rwos](https://drone.discourse.group/u/rwos)\
**Post date:** [January 27, 2020, 1:34pm UTC](https://drone.discourse.group/t/drone-cli-exec-network-switch-does-nothing/10453/2 "2020-01-27T13:34:49Z")

</div>

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:

> <https://github.com/drone/drone-runtime/blob/38f28a11afe8/engine/docker/docker.go#L185>

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.
