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

  • CircleCI: Best way to verify if docker containers are responding via HTTP
  • Assign LAN IP address to Docker container different from host's IP address
  • Can a container with STATUS “Exited (-1)” be fixed?
  • docker-compose v3 + apache spark, connection refused on port 7077
  • How to install a pip package locally in Dockerfile?
  • What is Container as a Service
  • Docker: Run command while another command is running
  • Setting volumes in docker-compose.yml file for windows 10 home
  • Using Ansible,Jenkins and docker to build fast test environments
  • Dynamically Pull Docker Image using chef recipe
  • Execute bash command if docker container does not exist
  • Waiting for a Docker container to be ready
  • 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(
        image='josepainumkal/vwadaptor:jose_toolUI',
        host_config=host_config
    ) 
    client.start(container=container.get('Id'))
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.