Skip to content

create/run -P (publish all exposed ports to random ports) is unsupported #3000

@shadjiiski

Description

@shadjiiski

In docker it is possible to have a single or all of the exposed ports published to a random (not specified by the user) port. I have tried to achieve the same via docker CLI and remote API and it is not working on VIC.

VIC Version:

JFrog Bintray build 6511

Docker Code

# Publish a single port
curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{"Image": "docker.io/kitematic/hello-world-nginx", "NetworkMode": "bridge", "PortBindings": {"80/tcp": [{"HostPort": ""}]}}' http:/containers/create?name=remote-test-1

# Publish all exposed ports
curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{"Image": "docker.io/kitematic/hello-world-nginx", "NetworkMode": "bridge", "PublishAllPorts": true}' http:/containers/create?name=remote-test-2

VIC Code

#Publish a single port
curl -k -H "Content-Type: application/json" -d '{"Image": "docker.io/kitematic/hello-world-nginx", "NetworkMode": "bridge", "PortBindings": {"80/tcp": [{"HostPort": ""}]}}' https://$IP:2376/containers/create?name=remote-test-1

# Publish all exposed ports
curl -k -H "Content-Type: application/json" -d '{"Image": "docker.io/kitematic/hello-world-nginx", "NetworkMode": "bridge", "PublishAllPorts": true}' https://$IP:2376/containers/create?name=remote-test-2

Expected behavior:
Having port 80 published in all cases like in docker: (after both containers have been started)

docker ps
CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                     NAMES
47ba36a21cad        docker.io/kitematic/hello-world-nginx   "sh /start.sh"           2 minutes ago       Up About a minute   0.0.0.0:32793->80/tcp     remote-test-2
38daf3db7ad6        docker.io/kitematic/hello-world-nginx   "sh /start.sh"           3 minutes ago       Up About a minute   0.0.0.0:32792->80/tcp     remote-test-1
docker inspect remote-test-X
...
    "NetworkSettings": {
            ...,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32792"
                    }
                ]
            },
            ...
    }
...

Actual behavior:
On VIC none of the containers has its ports published: (after both containers have been started)

 docker --tls ps
CONTAINER ID        IMAGE                                   COMMAND             CREATED             STATUS              PORTS                         NAMES
0cd8ce462aed        docker.io/kitematic/hello-world-nginx   "sh /start.sh"      18 minutes ago      Up 16 minutes                                     remote-test-2
91399d708c1f        docker.io/kitematic/hello-world-nginx   "sh /start.sh"      19 minutes ago      Up 16 minutes                                     remote-test-1
docker inspect remote-test-1
...
        "NetworkSettings": {
            ...,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": ""
                    }
                ]
            },
        ...
        }
...
docker inspect remote-test-2
...
        "NetworkSettings": {
            ...,
            "Ports": {
                "80/tcp": null
            },
        ...
        }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureNew functionality you could include in marketing materialpriority/p2product/admiralRelated to the vSphere Integrated Containers Managment Portalsource/customerReported by a customer, directly or via an intermediaryteam/container

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions