Docker Container's PublicPort via Remote API

How can I get the publicport from a running container by using the remote api? The information does not seem to be available in list or inspect containers. On creation of the container I allowing Docker to set the publicport randomly due to the large number of containers being spun up.

Thanks much for the thoughts.

  • How to create a docker cluster with MQ without Kubernetes
  • Unable to start mesos-slave after adding containerizer setting on slave
  • Docker 1.12 on Mac issue with DB connection pool
  • Swarm container not getting started with created overlay network
  • Unable to run cygwin in Windows Docker Container
  • Tracks stops working when volume is specified
  • Random tag applied to every git commit
  • ASP.NET Core 1.0 EF7 System.Data.SqlClient not found
  • How to move postgres into docker container?
  • docker-compose.yml with multiple env_files
  • Docker - dynamic regex-based sed substitution in files
  • Why would a service that works locally be getting kill signals frequently in docker?
  • 2 Solutions collect form web for “Docker Container's PublicPort via Remote API”

    It’s listed under NetworkSettings in the inspect:

    curl http://localhost:2375/containers/650eeb3c5d63/json
    ...
    "Ports":{
       "443/tcp":[{"HostIp":"0.0.0.0","HostPort":"32768"}],
       "80/tcp":[{"HostIp":"0.0.0.0","HostPort":"32769"}]}
    ...
    
    bash$ docker port 650eeb3c5d63
    443/tcp -> 0.0.0.0:32768
    80/tcp -> 0.0.0.0:32769
    

    if i’m not mistaken its under

     "HostConfig": {
                "PortBindings": {
                    "3306/tcp": [
                        {
                            "HostIp": "",
                            "HostPort": "3309"
                        }
                    ]
                },
                "RestartPolicy": {
                    "Name": "no",
                    "MaximumRetryCount": 0
                },
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.