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

  • yum repomd.xml does not match in gitlab-ci docker build
  • How to set no-ack for RabbitMQ with docker?
  • Overlay network aware HAProxy
  • How to run docker-compose as root user Docker Cloud
  • How to log PHP errors in an AWS Elastic Beanstalk Docker container
  • Packer instance accessing private Docker registry in AWS
  • 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.

  • Having trouble getting docker to work on mac
  • Non-Alpine dind docker image
  • Can I publish a .Net application which is not ASP.NET 5 or ASP.NET Core in Docker containers?
  • Drupal website with Docker-Compose
  • filedescriptor out of range in select() using requests
  • Highlighting docker commands in vim
  • 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.