docker remote api cannot bind a port to a host

I was trying to use docker‘s remote api to bind a host, but it always fails.

I pass this dict using python and urllib2:

  • Kubernetes installation conflicts with docker-ce-17.03.0
  • Running Docker image gives: Unable to load configuration from
  • How MongoDB works with Docker
  • Adding CPUs accessible by docker for TensorFlow on Windows 10
  • Docker volume plugin marathon
  • Silently Installing pecl modules (e.g. pecl_http) Inside a Docker Container?
  • {

    Then I use remote api to inspect container, it gives me the following:


    I also tried to use the method in this link Binding a port to a host interface using the REST API,
    but when I posted data to start the container, it will raise HTTP Error 500. So I guess whether the docker remote api had been changed.

  • meteor up listen tcp bind: address already in use
  • Xdebug can't connect back to Docker host
  • An core web API with swagger doesn’t work in Docker in Azure
  • Mixed HTTP / HTTPS content with Gitlab behind a reverse proxy
  • Grunt / Docker file paths
  • How to access to Google AppEngine Managed VM logs?
  • One Solution collect form web for “docker remote api cannot bind a port to a host”

    Looks like your PortBindings parameter is slightly off. You’re missing "HostPort":

    Change it to:

    'HostConfig':{'PortBindings':{'80/tcp':[{ "HostPort": '15080' }] }}

    From the docs:

    • PortBindings – A map of exposed container ports and the host port they should map to. It should be specified in the form {
      <port>/<protocol>: [{ “HostPort”: “<port>” }] } Take note that port
      is specified as a string and not an integer value.
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.