Docker-py: Publish service port in host mode

Created on 29 Jan 2018  路  6Comments  路  Source: docker/docker-py

Hello,

I'm trying to create a service publishing a port in host mode with the Python SDK, but i don't see option to do so :(

It is possible via docker command line (https://docs.docker.com/engine/reference/commandline/service_create/#options) :
docker service create -p mode=host,published=80,target=80 --name test httpd

It is also possible via docker-compose:
services: test: image: httpd ports: - mode: host target: 80 published: 80 deploy: mode: replicated replicas: 1

Is there a way to achieve the same result via python SDK ?

Thanks !

grouapi-upgrade kinfeature-request

Most helpful comment

@jgeryk I believe you are mistaken.

Exposed ports that this service is accessible on from the outside, in the form of [...] { published_port: <port_config_tuple> }. Port config tuple format is (target_port [, protocol [, publish_mode]]).

All 6 comments

Hello @feliperuhland , thanks for your reply !

In fact, EndpointSpec only support "vip" and "dnsrr" modes. I'm looking for the "host" mode. IMHO it is even not the same kind of 'mode' we are speaking about.... If i understand well, "vip"/"dnsrr" mode refers to internal swarm load-balancing mode, the "host" mode i'm looking for refers to external port publishing...

A more precise link from docker documentation: https://docs.docker.com/engine/reference/commandline/service_create/#publish-service-ports-externally-to-the-swarm--p-publish

Regards

@greenmaid You're right - we don't have support for it currently, unfortunately. Thanks for bringing it to our attention.

It looks like there still isn't a way to create a service with published ports using mode=host i.e., without the routing mesh.
EDIT: The Docker REST API does support this in /services/create/ (EndpointSpec->Ports->PublishMode)

@jgeryk I believe you are mistaken.

Exposed ports that this service is accessible on from the outside, in the form of [...] { published_port: <port_config_tuple> }. Port config tuple format is (target_port [, protocol [, publish_mode]]).

I don't know how I missed that. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

treuherz picture treuherz  路  4Comments

AdamWRichardson picture AdamWRichardson  路  4Comments

ko-christ picture ko-christ  路  3Comments

miracle2k picture miracle2k  路  4Comments

andornaut picture andornaut  路  5Comments