How to bind a port when using docker-py to create a service? [duplicate]

This question already has an answer here:

  • how to bind ports with docker-py

    2 answers

  • why won't my fluentd work with elasticsearch
  • How to completely destroy docker container from marathon UI?
  • Docker : Could not resolve host: - for go get ./
  • Unable to connect to Docker Nginx build
  • I'm unable to connect Docker Remote API using nodejs hosted in AWS
  • docker-compose service version error
  • MySQL -> .NET Core Dependency error (MySql.Data)
  • Change default instance disk size in the kubernetes-jenkins plugin
  • how to configure docker to use apache and php in separate containers
  • Docker Java Client in JMeter
  • How to copy files from shared directory in multiple Dockerfile?
  • How to check that the docker container is restarted and accessible?
  • One Solution collect form web for “How to bind a port when using docker-py to create a service? [duplicate]”

    Try the below code:

    port_bindings={1111: [5033, 5035]}
    host_config = client.create_host_config(
        port_bindings = port_bindings
    container = client.create_container(
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.