Document way to create a container with a network with links.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
I'm currently unable to find any documentation on a way to create and start a container that is connected to a specific network (not the default bridge) and uses links without first creating the container on the default bridge, then connecting the container to the network with the links necessary and then disconnecting it from the default bridge. I'd like to be able to create a container and attach it directly to the specified network with links without ever attaching it or removing it from the default bridge.
Here's an example of what I'm doing:
docker network create foo
docker run -it --name=alpine --network=foo alpine
>>> import docker
>>> c = docker.from_env()
>>> c.containers.run('bfirsh/reticulate-splines', detach=True)
>>> c.networks.list()
>>> foo = c.networks.list(names=['foo'])
>>> foo[0].connect('inspiring_montalcini', links=[('alpine', 'alpine')])
>>> bridge = c.networks.list(names=['bridge'])
>>> bridge[0].disconnect('inspiring_montalcini')
Which works, but ideally I'd like to be able to specify the network with links in the containers.run command so the container doesn't first have to exist on the wrong network (default bridge) and then later get removed from it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the containers.run call and the networks connect/disconnect examples in the issue. Check the docker-py API behavior for specifying a network and links during container creation, then document the supported invocation and any limitation if it is not supported. Done means a reader can create the container on the requested network without relying on the default-bridge workaround, or can clearly understand the required sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100