Repository navigation
Closed
Labels
Description
Description
Start a container:
dmp@lima-main-2025-05-15:/Users/dmp/Projects/go/nerd/nerdctl$ nerdctl run -d --name nerdctl-diagnostics2 -p 9044:80 nginx
d1364e3fb6f5bbc1de316656c9d7df483959e0c3e7202008f212ebe6c5bcd8d2
Check iptables:
dmp@lima-main-2025-05-15:/Users/dmp/Projects/go/nerd/nerdctl$ while read -r line; do sudo nsenter --net=$line iptables-save; done < <(lsns -n -u -t net -o PATH) | grep " 9044 "
-A CNI-DN-4095fe68ef51b84d4d4bd -s 10.4.0.0/24 -p tcp -m tcp --dport 9044 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-4095fe68ef51b84d4d4bd -s 127.0.0.1/32 -p tcp -m tcp --dport 9044 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-4095fe68ef51b84d4d4bd -p tcp -m tcp --dport 9044 -j DNAT --to-destination 10.4.0.83:80
-A CNI-HOSTPORT-DNAT -p tcp -m comment --comment "dnat name: \"bridge\" id: \"default-d1364e3fb6f5bbc1de316656c9d7df483959e0c3e7202008f212ebe6c5bcd8d2\"" -m multiport --dports 9044 -j CNI-DN-4095fe68ef51b84d4d4bd
So far, all fine.
Start a new container, different name, same port binding:
dmp@lima-main-2025-05-15:/Users/dmp/Projects/go/nerd/nerdctl$ nerdctl run -d --name nerdctl-diagnostics3 -p 9044:80 nginx
FATA[0000] failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running createRuntime hook #0: exit status 1, stdout: , stderr: time="2025-05-15T15:11:33-07:00" level=fatal msg="failed to expose ports in rootless mode: conflict with ID 16"
Not happy about port conflict - expected.
Now check iptables again:
dmp@lima-main-2025-05-15:/Users/dmp/Projects/go/nerd/nerdctl$ while read -r line; do sudo nsenter --net=$line iptables-save; done < <(lsns -n -u -t net -o PATH) | grep " 9044 "
-A CNI-DN-4095fe68ef51b84d4d4bd -s 10.4.0.0/24 -p tcp -m tcp --dport 9044 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-4095fe68ef51b84d4d4bd -s 127.0.0.1/32 -p tcp -m tcp --dport 9044 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-4095fe68ef51b84d4d4bd -p tcp -m tcp --dport 9044 -j DNAT --to-destination 10.4.0.83:80
-A CNI-DN-89454d63e9c74ec13be4f -s 10.4.0.0/24 -p tcp -m tcp --dport 9044 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-89454d63e9c74ec13be4f -s 127.0.0.1/32 -p tcp -m tcp --dport 9044 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-89454d63e9c74ec13be4f -p tcp -m tcp --dport 9044 -j DNAT --to-destination 10.4.0.84:80
-A CNI-HOSTPORT-DNAT -p tcp -m comment --comment "dnat name: \"bridge\" id: \"default-d1364e3fb6f5bbc1de316656c9d7df483959e0c3e7202008f212ebe6c5bcd8d2\"" -m multiport --dports 9044 -j CNI-DN-4095fe68ef51b84d4d4bd
-A CNI-HOSTPORT-DNAT -p tcp -m comment --comment "dnat name: \"bridge\" id: \"default-82214d1802aee04278e8410ac445e17610877d63eca40a5c2d25dace25b07271\"" -m multiport --dports 9044 -j CNI-DN-89454d63e9c74ec13be4f
Steps to reproduce the issue
^
Describe the results you received and expected
Left over iptables rules after failed container creation, possibly resulting in broken networking.
This is possibly the reason for #4246 and maybe other of our port binding issues.
What version of nerdctl are you using?
main
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
Host information
No response
Activity
[-][Network]: Failed container creation will f-up iptables rules[/-][+][NET]: Failed container creation will f-up iptables rules[/+][-][NET]: Failed container creation will f-up iptables rules[/-][+][NET]: oci onCreateRuntime error will leave behind broken iptables rules[/+]apostasie commentedon Jun 6, 2025
Presumably fixed by #4255