I am doing:
api.containers.run(
...,
networks=['foo']
)
This has no effect. The container will instead be part of the default bridge.
The command apparently sends this to the API:
{...,
'NetworkingConfig': {'foo': None}
}
What is the correct way to use this?
Hi,
Unfortunately that looks like a bug on our end. I believe you should be able to do the same thing using the network_mode parameter, i.e
api.containers.run(
...
network_mode='foo'
)
Hope that helps
Was affected by this bug/unexpected usage today but @shin-'s suggestion worked.
````
import docker
client = docker.from_env()
network = client.networks.create("mynetwork")
c1 = client.containers.run('alpine', 'echo hello', detach=True, name="c1", network_mode=network.name)
c2 = client.containers.run('alpine', 'echo hello', detach=True, name="c2", network_mode=network.name)
network.reload()
print network.containers
````
Why is this closed? How is networks supposed to be used? The documentation should be updated for both params, as this is not clear in any way.
master.networks will be removed in the next release, as it has never worked to begin with.master along with the code itself.
Most helpful comment
Hi,
Unfortunately that looks like a bug on our end. I believe you should be able to do the same thing using the
network_modeparameter, i.eHope that helps