Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker-Compose Ignores Exposed TCP/UDP on same Port #7627

Closed
moloch-- opened this issue Jul 25, 2020 · 8 comments
Closed

Docker-Compose Ignores Exposed TCP/UDP on same Port #7627

moloch-- opened this issue Jul 25, 2020 · 8 comments

Comments

@moloch--
Copy link

@moloch-- moloch-- commented Jul 25, 2020

Description of the issue

Docker Compose ignore rules mapping both TCP and UDP to the same port, and does not produce an error or warning.

For example:

version: '3.8'

services:
  foobar:
    build: ./foobar-server
    ports:
      - "13100:13100/tcp"
      - "13101:13101/tcp"
      - "13102:13102/tcp"
      - "13100:13100/udp"
      - "13101:13101/udp"
      - "13102:13102/udp"

Results in:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                  NAMES
59468a55e31b        foo_bar       "/opt/entrypoint con…"   35 minutes ago      Up 7 minutes        0.0.0.0:13100-13102->13100-13102/tcp   foo_bar_1

Docker inspect shows:

        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "d797c60152a36a7762e6bb77f01119cc3d39e40333d3b6c98aa19d5587425663",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "13100/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "13100"
                    }
                ],
                "13101/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "13101"
                    }
                ],
                "13102/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "13102"
                    }
                ]
            },

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.26.2, build eefe0d31
docker-py version: 4.2.2
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:45:44 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:44:15 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

$ docker-compose config
services:
  foo:
    build:
      context: /home/moloch/foo/foo-server
    ports:
    - protocol: tcp
      published: 13100
      target: 13100
    - protocol: tcp
      published: 13101
      target: 13101
    - protocol: tcp
      published: 13102
      target: 13102
    - protocol: udp
      published: 13100
      target: 13100
    - protocol: udp
      published: 13101
      target: 13101
    - protocol: udp
      published: 13102
      target: 13102
    volumes:
    - /home/moloch/foo/data:/data:rw
version: '3.8'

Steps to reproduce the issue

  1. Map a TCP/UDP port
  2. docker-compose up

Observed result

Docker compose only maps the TCP port (or first occurrence).

Expected result

Docker Compose maps both TCP/UDP to the specified port, or produces an error message.

@moloch-- moloch-- changed the title Docker-Compose Ignore Exposed TCP/UDP on same Port Docker-Compose Ignores Exposed TCP/UDP on same Port Jul 25, 2020
@quentinsf
Copy link

@quentinsf quentinsf commented Oct 21, 2020

As a workaround, I found that if I didn't make the port specifications identical, it would accept both. In my case, I wanted both tcp and udp on port 24224, so I requested UDP for that port and TCP for a range which included it.

    ports:
      - "24223-24225:24223-24225/tcp"
      - "24224:24224/udp"

This seems to have worked, though I confess I haven't tested it with actual code yet!

@stale
Copy link

@stale stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 2, 2021
@Erikvv
Copy link

@Erikvv Erikvv commented Jun 3, 2021

I don't have this issue in 1.28.6. Looks fixed.

@stale
Copy link

@stale stale bot commented Jun 3, 2021

This issue has been automatically marked as not stale anymore due to the recent activity.

@stale stale bot removed the stale label Jun 3, 2021
@victorelec14
Copy link

@victorelec14 victorelec14 commented Aug 27, 2021

is fixed or still happens ? , Issue can be close ? thanks

@Shadowghost
Copy link

@Shadowghost Shadowghost commented Sep 2, 2021

I just tried it with docker-compose version 1.29.2, build 5becea4c and it works fine:

    ports:
      - 53:53/tcp
      - 53:53/udp
docker-pr 394106 root    4u  IPv4 367329      0t0  TCP *:domain (LISTEN)
docker-pr 394113 root    4u  IPv6 367334      0t0  TCP *:domain (LISTEN)
docker-pr 394129 root    4u  IPv4 368436      0t0  UDP *:domain
docker-pr 394135 root    4u  IPv6 368440      0t0  UDP *:domain

@Cobertos
Copy link

@Cobertos Cobertos commented Sep 22, 2021

This seems to be fixed, I also just tried on docker-compose version 1.29.2, build 5becea4c

@ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Sep 23, 2021

also tested on compose v2 and works as expected

@ndeloof ndeloof closed this Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants