Description
The nerdctl will always use tcp port 49153 as a random port if hostport is not set when using -p/--publish flag.
Multiple rule will be created in iptable nat tables as well
sudo iptables -nvL -t nat
Steps to reproduce the issue
Multiple containers
x@build-ubuntu-01:~$ sudo nerdctl run --cni-path=/opt/cni/bin -d -p 80 --name nginx-1 nginx
90de08eaa44da1b62dc1495f8fd1ef0b35e1657d63d5e08032ac71452e5b12a4
x@build-ubuntu-01:~$ sudo nerdctl run --cni-path=/opt/cni/bin -d -p 80 --name nginx-2 nginx
2adc259619176c4f2794ddc6dfde3c9d2c45e74b75c6a5a1bab0e73ab8e6920f
x@build-ubuntu-01:~$ sudo nerdctl port nginx-1
80/tcp -> 0.0.0.0:49153
x@build-ubuntu-01:~$ sudo nerdctl port nginx-2
80/tcp -> 0.0.0.0:49153
One container with multiple ports
x@build-ubuntu-01:~$ sudo nerdctl run --cni-path=/opt/cni/bin -d -p 80,81 --name nginx-3 nginx
ab075107d48ed3d54d08935351156c5b8880799112be5bb6a651e0e8e3fb6b54
x@build-ubuntu-01:~$ sudo nerdctl port nginx-3
80/tcp -> 0.0.0.0:49153
81/tcp -> 0.0.0.0:49153
compose
If multiple ports are defined without host ports in compose file, the same issue will occur.
Describe the results you received and expected
The auto-generated ports are available.
What version of nerdctl are you using?
$ nerdctl --version
nerdctl version 1.0.0
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
No response
Host information
$ sudo nerdctl info
Client:
Namespace: default
Debug Mode: false
Server:
Server Version: 1.4.12
Storage Driver: overlayfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Log: fluentd journald json-file syslog
Storage: aufs native overlayfs
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-90-generic
Operating System: Ubuntu 20.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.39GiB
Name: build-ubuntu-01
ID: a2c61eb4-be6e-45d9-ba8e-a9933e17bf9a
WARNING: No swap limit support
Description
The nerdctl will always use tcp port
49153as a random port if hostport is not set when using-p/--publishflag.Multiple rule will be created in iptable nat tables as well
Steps to reproduce the issue
Multiple containers
One container with multiple ports
compose
If multiple ports are defined without host ports in compose file, the same issue will occur.
Describe the results you received and expected
The auto-generated ports are available.
What version of nerdctl are you using?
$ nerdctl --version
nerdctl version 1.0.0
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
No response
Host information
$ sudo nerdctl info Client: Namespace: default Debug Mode: false Server: Server Version: 1.4.12 Storage Driver: overlayfs Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Log: fluentd journald json-file syslog Storage: aufs native overlayfs Security Options: apparmor seccomp Profile: default Kernel Version: 5.4.0-90-generic Operating System: Ubuntu 20.04.5 LTS OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 15.39GiB Name: build-ubuntu-01 ID: a2c61eb4-be6e-45d9-ba8e-a9933e17bf9a WARNING: No swap limit support