How to launch a docker bundle with specified exposed ports?

If you are not familiar with docker bundles please read this.

So I have tried to create a simple docker bundle from the following docker-compose.yml

  • Unable to browse nodejs web app running docker container
  • Thousands of cAdvisor Docker containers created until disk runs out of space
  • How to setup hostnames using docker-compose?
  • Tag not found in repository docker.io/minio
  • How can i install my package automatically on docker container
  • What is a sidekick container?
  • version: "2"
    services:
      web:
        image: cohenaj194/apache-simple
        ports:
          - 32701:80
      nginx:
        image: nginx
        ports:
          - 32700:80
    

    But the ports of the docker services this bundle created were not exposed and I could not access any of the containers in my services through ports 32700 or 32701 as I specified it in thedocker-compose.yml. How am I supposed to expose the ports of docker bundle services?

    Update: I believe my issue may be that my test.dab file that is created with docker-compose bundle does not contain any mention of port 32700 or 32701:

    {
      "Services": {
        "nginx": {
          "Image": "nginx@sha256:d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6", 
          "Networks": [
            "default"
          ], 
          "Ports": [
            {
              "Port": 80, 
              "Protocol": "tcp"
            }
          ]
        }, 
        "web": {
          "Image": "cohenaj194/apache-simple@sha256:6196c5bce25e5f76e0ea7cbe8e12e4e1f96bd36011ed37d3e4c5f06f6da95d69", 
          "Networks": [
            "default"
          ], 
          "Ports": [
            {
              "Port": 80, 
              "Protocol": "tcp"
            }
          ]
        }
      }, 
      "Version": "0.1"
    }
    

    Attempting to insert the extra ports into this file also does not work and results in the following error:

    Error reading test.dab: JSON syntax error at byte 229: invalid character ':' after object key:value pair
    

    Update2: My services are accessible over the default ports docker swarm assigns to services when the host port is not defined:

    user@hostname:~/test$ docker service inspect test_nginx --pretty
    ID:     3qimd4roft92w3es3qooa9qy8
    Name:       test_nginx
    Labels:
     - com.docker.stack.namespace=test
    Mode:       Replicated
     Replicas:  2
    Placement:
    ContainerSpec:
     Image:     nginx@sha256:d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6
    Networks: 1v5nyqqjnenf7xlti346qfw8n
    Ports:
     Protocol = tcp
     TargetPort = 80
     PublishedPort = 30000
    

    I can then get at my service from port 30000 however I want to be able to define the host port my services will use.

  • How did docker daemon limit container's disk bandwidth like docker run --device-read-bps
  • Docker compose permission denied on cento 7 when creating mysql database Linux issue
  • Docker, install postgresql in a container contain “ubuntu:14.04”, lost when out of the container
  • multiple eth configuration using docker
  • Cannot ping server after docker run
  • Docker compose not exposing port for application container
  • 2 Solutions collect form web for “How to launch a docker bundle with specified exposed ports?”

    As of the Docker 1.12 release, there is no way to specify a “published” port in the bundle. The bundle is a portable format, and exposed ports are non-portable (in that if two bundles used the same ones they would conflict).

    So exposed ports will not be part of the bundle configuration. Currently the only option is to run a docker service update to add the published port. In the future there may be other ways to achieve this.

    docker run with the flag -p $localport:$containerport

    Edit:

    Are you checking the exposed port with docker ps?

    use docker service inspect

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.