You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Run 2 containers with -p <hostport>:<containerport> option.
$ nerdctl run -d --name=my-nginx -p 5000:80 nginx
187eda2196935949563e57cb9227da1c9efafef4fda3aefe54a00b53635fa950
$ nerdctl run -d --name=my-httpd -p 5000:80 httpd
$ nerdctl ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
187eda219693 docker.io/library/nginx:latest "/docker-entrypoint.…" 9 minutes ago Up 0.0.0.0:5000->80/tcp my-nginx
27232786d099 docker.io/library/httpd:latest "httpd-foreground" 10 seconds ago Up 0.0.0.0:5000->80/tcp my-httpd2
a22d1643e952 docker.io/library/httpd:latest "httpd-foreground" 33 seconds ago Created 0.0.0.0:5000->80/tcp my-httpd
This is very similar to 2164 except this is for user specified host ports.
Both the containers have host port 5000 and is up but only one of them can be reached from the host.
Describe the results you received and expected
Error response
Similar response as docker. Ports are not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0:0: listen tcp 0.0.0.0:5000: bind: address already in use.
Happy to PR by extracting a function to check used ports in port allocate and checking if port is already in use before running the container on linux host.
It seems like there is already code in portAllocate to check if a given port is already in use?. Probably the logic is a little flaky? Also, FWIW, checking /proc/net/<tcp|udp> is prone to race conditions. There could be two processes trying to get a hold on the same port, but the kernel won't report it as “used” for neither of them. Thus, but processes will attempt to bind to the port but only one of them will succeed, even after validating that the port wasn't in use.
Description
Running containers with
-p/--publish
with user provided host port does not check if the host port is already in use in both rootful and rootless. This issue is very similar to #2164.Steps to reproduce the issue
This is very similar to 2164 except this is for user specified host ports.
Both the containers have host port 5000 and is up but only one of them can be reached from the host.
Describe the results you received and expected
Error response
Similar response as docker.
Ports are not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0:0: listen tcp 0.0.0.0:5000: bind: address already in use.
What version of nerdctl are you using?
main branch
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
Lima
Host information
The text was updated successfully, but these errors were encountered: