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

  • Docker deployment workflow with git
  • Using commands in bluemix user interface
  • From local development to dockerized microservices
  • how to schedule job with the monitoring of cpu,memory, disk io, etc.
  • Add dictionary file to postgresql docker container
  • Api-Testing getting a mess with vagrant
  • Cannot finde module 'express' (node app with docker)
  • Can I connect to remote DB server from inside docker container?
  • How to trigger a Liveness Probe failure in kubernetes
  • Docker interrupt proxy internet connection
  • Docker images with visual(X) support? Or should I use VBox instead in this case?
  • Sharing directories in a Docker container both with a Dockerfile and after the container is running
  • 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.