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

EXPOSE does not support port ranges #12293

Closed
colinbendell opened this issue Nov 14, 2021 · 6 comments · Fixed by #12305
Closed

EXPOSE does not support port ranges #12293

colinbendell opened this issue Nov 14, 2021 · 6 comments · Fixed by #12305
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@colinbendell
Copy link
Contributor

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

EXPOSE with a port range (eg: EXPOSE 20000-20100) in a Dockerfile throws a parsing error when attempting to run the image.

Error: unable to convert image EXPOSE statement "20000-20100/tcp" to port number: strconv.Atoi: parsing "20000-20100": invalid syntax

Likely related to: https://github.com/containers/podman/blob/main/pkg/specgen/generate/ports.go#L416-L423

Steps to reproduce the issue:

  1. Dockerfile with:
FROM alpine
EXPOSE 20000-20100
  1. podman build --tag portrangetest .

STEP 1/2: FROM alpine
STEP 2/2: EXPOSE 20000-20100
--> Using cache 81bef6fdd879967daea2eab5dcb14a90ac9e4a133b8c0b4784284a9eddd074ba
COMMIT portrangetest
--> 81bef6fdd87
Successfully tagged localhost/portrangetest:latest
81bef6fdd879967daea2eab5dcb14a90ac9e4a133b8c0b4784284a9eddd074ba

  1. podman run --rm -it -P portrangetest

Describe the results you received:

Error: unable to convert image EXPOSE statement "20000-20100/tcp" to port number: strconv.Atoi: parsing "20000-20100": invalid syntax

Describe the results you expected:

Expect no error

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Client:
Version:      3.4.2
API Version:  3.4.2
Go Version:   go1.17.2
Built:        Fri Nov 12 11:08:25 2021
OS/Arch:      darwin/arm64

Server:
Version:      3.4.1
API Version:  3.4.1
Go Version:   go1.16.8
Built:        Wed Oct 20 10:32:52 2021
OS/Arch:      linux/arm64

Output of podman info --debug:

host:
  arch: arm64
  buildahVersion: 1.23.1
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.0.30-2.fc35.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.30, commit: '
  cpus: 4
  distribution:
    distribution: fedora
    variant: coreos
    version: "35"
  eventLogger: journald
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.14.14-300.fc35.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 5771919360
  memTotal: 6190661632
  ociRuntime:
    name: crun
    package: crun-1.2-1.fc35.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.2
      commit: 4f6c8e0583c679bfee6a899c05ac6b916022561b
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.12-2.fc35.aarch64
    version: |-
      slirp4netns version 1.1.12
      commit: 7a104a101aa3278a2152351a082a6df71f57c9a3
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.0
  swapFree: 0
  swapTotal: 0
  uptime: 12m 35.35s
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /var/home/core/.config/containers/storage.conf
  containerStore:
    number: 1
    paused: 0
    running: 0
    stopped: 1
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/home/core/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 351
  runRoot: /run/user/1000/containers
  volumePath: /var/home/core/.local/share/containers/storage/volumes
version:
  APIVersion: 3.4.1
  Built: 1634740372
  BuiltTime: Wed Oct 20 14:32:52 2021
  GitCommit: ""
  GoVersion: go1.16.8
  OsArch: linux/arm64
  Version: 3.4.1

Package info (e.g. output of rpm -q podman or apt list podman):

brew list podman
/opt/homebrew/Cellar/podman/3.4.2/bin/podman
/opt/homebrew/Cellar/podman/3.4.2/bin/podman-remote
/opt/homebrew/Cellar/podman/3.4.2/etc/bash_completion.d/podman
/opt/homebrew/Cellar/podman/3.4.2/libexec/gvproxy
/opt/homebrew/Cellar/podman/3.4.2/share/fish/vendor_completions.d/podman.fish
/opt/homebrew/Cellar/podman/3.4.2/share/man/ (160 files)
/opt/homebrew/Cellar/podman/3.4.2/share/zsh/site-functions/_podman```

**Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)**


Yes

**Additional environment details (AWS, VirtualBox, physical, etc.):**
macOS with qemu
@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 14, 2021
@rhatdan
Copy link
Member

rhatdan commented Nov 15, 2021

@Luap99 @mheon is Buildah writing out the wrong thing or is this a Podman bug?

@rhatdan
Copy link
Member

rhatdan commented Nov 15, 2021

@colinbendell does the image work with Docker. or is the image bad?

@colinbendell
Copy link
Contributor Author

colinbendell commented Nov 15, 2021

does the image work with Docker. or is the image bad?

This is a valid image in Docker. It is poorly documented though in Docker.

@Luap99
Copy link
Member

Luap99 commented Nov 15, 2021

The oci spec https://github.com/opencontainers/image-spec/blob/main/config.md only documents the port/protocol syntax.
I also do not find that syntax in the docker documentation for the EXPOSE key in a dockerfile https://docs.docker.com/engine/reference/builder/#expose.
Given that it is very easy to support without breaking changes we should fix it anyway.
Buildah also happily builds an image with EXPOSE 8080-8081 so supporting it makes sense.

@mheon
Copy link
Member

mheon commented Nov 15, 2021

I thought the existing code already handled ranges for expose, but I could well be wrong. Concur we should fix it.

@colinbendell
Copy link
Contributor Author

I thought the existing code already handled ranges for expose, but I could well be wrong. Concur we should fix it.

The --expose run parameter does support ranges. The attached PR just re uses the logic.

colinbendell added a commit to colinbendell/podman that referenced this issue Nov 21, 2021
Fixes issue containers#12293. EXPOSE directive in images should mirror the --expose
parameter. Specifically `EXPOSE 20000-20100/tcp` should work the same
as `--expose 20000-20100/tcp`

Signed-off-by: Colin Bendell <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants