How to launch a docker bundle with specified exposed ports? -


if not familiar docker bundles please read this.

so have tried create simple docker bundle following docker-compose.yml

version: "2" services:   web:     image: cohenaj194/apache-simple     ports:       - 32701:80   nginx:     image: nginx     ports:       - 32700:80 

but ports of docker services bundle created not exposed , not access of containers in services through ports 32700 or 32701 specified in thedocker-compose.yml. how supposed expose ports of docker bundle services?

update: believe issue may test.dab file created docker-compose bundle not contain 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 insert ports file not work , results in following error:

error reading test.dab: json syntax error @ byte 229: invalid character ':' after object key:value pair 

update2: services accessible on default ports docker swarm assigns services when host port 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 @ service port 30000 want able define host port services use.

as of docker 1.12 release, there no way specify "published" port in bundle. bundle portable format, , exposed ports non-portable (in if 2 bundles used same ones conflict).

so exposed ports not part of bundle configuration. option run docker service update add published port. in future there may other ways achieve this.


Comments