docker (2.0.2) - Unable to publish ports with containers.run()
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Seem to be unable to publish ports to the host w/ docker run. Perhaps I'm doing something wrong
conatiner = client.containers.run(
image='mongo:3.2.11',
detach=True,
name='name',
network_mode='host',
ports={
'{}/tcp'.format(27017): ('127.0.0.1', 30000)
},
publish_all_ports=True
)
},
"NetworkMode": "host",
"PortBindings": {
"27017/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "30000"
}
]
},
...
"NetworkSettings": {
"Bridge": "",
"SandboxID": "e9f4cd55c0cefbdf485733c297a4209d24a427803da1a06c0e1a632d5802f311",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/default",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
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 shown in the report and reproduce it using network_mode='host', the ports mapping, and publish_all_ports=True. Compare the resulting PortBindings and NetworkSettings with the expected host-port behavior; done means the issue is fixed or the supported behavior is clearly established and covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100