How to run basic web app container in docker-py?
docker, dockerpy, python
Solution
I can confirm that this does not work.
This methods works ok, it may be useful for you:
container = c.create_container('kermit/hellonode', name='hello', ports=[1337])
c.start(container, publish_all_ports=True)
info = c.inspect_container(container)
host_port = info['NetworkSettings']['Ports']['1337'][0]['HostPort']
Then, you can access service at `0.0.0.0:<host_port>`
Problem
I am trying to mimic running a containerized web app exposed at some port ``` sudo docker run -d -p 1338:1337 kermit/hellonode ``` in Python using docker-py. So far I got this code to start the instance: ``` container = c.create_container('kermit/hellonode', name='hello') c.start(container, port_bindings={1337: ('0.0.0.0', 1338)}) ``` But I can't access the container at the public port 1338 (which works normally with the first command) - I'm getting connection refused errors. Does anyone know if I'm missing some option to make the Python call create the functional, accessible container? Inspecting the container tells me that the port is set up as it should be: ``` $ sudo docker port hello 1337 0.0.0.0:1338 ``` I also experimented with the `ports=[1337]` option in the `create_container` call, but it didn't help either. Update: seems this is some kind of bug. The workaround is to specify TCP explicitly: ``` container = c.create_container('kermit/hellonode', name='hello', ports=[(1337, 'tcp')]) ```