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

  • Rails server is still running in a new opened docker container
  • Create your own Docker (sub-)commands
  • Can't access app deployed with docker and google cloud
  • Why is my official Ghost.org Docker container serving old content after I refresh my browser even though Ghost / Node are in development mode?
  • Error response from daemon: chtimes /var/lib/docker/tmp/docker-export-$: invalid argument
  • google/cadvisor:latest image monitor container run error
  • 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.

  • Can docker log to multiple gelf destinations
  • How to create Docker-image from my app? It's node.js application that use MongoDB
  • Cross-device link not permitted Error in Meteor Project with Docker
  • Docker security issue
  • Keeping PostgreSQL data in docker and OSX
  • Can I store npm scripts outside of package.json, to avoid forcing Docker to refresh all modules on any npm script update?
  • 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.