Trouble publishing same port, two protocols using endpoint_spec
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
I'm working on a project where services will need both tcp and udp protocols published for the same ports. When I tried using types.EndpointSpec, the service would start, but with only one wrong port published:
"""
Note: I'm specifying `mode` here for verbosity . This service will only ever have a single
replica, so leaving it to its default would be equally valid.
"""
ep_spec = EndpointSpec(mode='vip', ports=[
{27015: (27015, 'tcp', 'host')},
{27015: (27015, 'udp', 'host')}
])
client.services.create(image=server_image,
args=svc_args,
name=img_name,
networks=['dgsm_default'],
endpoint_spec=ep_spec)
docker service ls:

docker container ls:

If I only do a single port, I get similar results:
ep_spec = EndpointSpec(mode='vip', ports=[
{27015: (27015, 'tcp', 'host')}
])
docker service ls:

docker container ls:

Setting ports to just a dict results in no published ports on the service, but the correct port on the container:
ep_spec = EndpointSpec(mode='vip', ports={27015: (27015, 'tcp', 'host')})
docker service ls:

docker container ls:

However, I found this comment on #1233 which led me to try this:
ep_spec = {'Ports': [
{'Protocol': 'tcp', 'PublishedPort': 27015, 'TargetPort': 27015, 'PublishMode': 'host'},
{'Protocol': 'udp', 'PublishedPort': 27015, 'TargetPort': 27015, 'PublishMode': 'host'}
]}
and both protocols show up for the port on the container, (not the service, but this service is reachable from outside the host now):
docker service ls:

docker container ls:

Am I reading this incorrectly?
Environment details:
(venv) [connor@bigdell dgsm]$ python -V
Python 3.8.0
(venv) [connor@bigdell dgsm]$ pip freeze | grep docker
docker==4.1.0
(venv) [connor@bigdell dgsm]$ docker --version
Docker version 19.03.2, build 6a30dfc
(venv) [connor@bigdell dgsm]$ cat /etc/*-release
CentOS Linux release 7.7.1908 (Core)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the EndpointSpec examples and the ServiceCollection.create documentation, then compare their generated service and container port specifications with the raw Ports dictionary example. Confirm whether both TCP and UDP mappings are represented on the service, and document or test the behavior using the reported Docker 4.1.0 and Engine 19.03.2 environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100