0

I want to manage the docker service automating. And I must bind a port to the service. But the docker service creating function in the docker SDK for python cannot bind a port. https://docker-py.readthedocs.io/en/stable/services.html Is there any method to figure out this problem?

Ben
  • 1
  • 1
  • Not a duplicated since question is about services not containers. A possible solution would be `client.services.create(my_image, endpoint_spec=docker.types.EndpointSpec(ports={80: 80}))` – Israel Varea Oct 15 '20 at 09:08

1 Answers1

0

Try the below code:

port_bindings={1111: [5033, 5035]}
host_config = client.create_host_config(
    port_bindings = port_bindings
)

container = client.create_container(
    image='josepainumkal/vwadaptor:jose_toolUI',
    host_config=host_config
) 
client.start(container=container.get('Id'))
josepainumkal
  • 1,613
  • 1
  • 16
  • 23