Commit b34858e
committed
fix: clean up port-reserver.pid and the parent dir when the container is removed
In the current implementation, when a container is started with the -p
option, a `sleep infinity` process is launched to reserve host ports.
The PID of this process is stored in
`/run/nerdctl/<namespace>/<container ID>/port-reserver.pid`.
When the container is removed, the following file and directory are
expected to be cleaned up.
- /run/nerdctl/<namespace>/<container ID>/port-reserver.pid
- /run/nerdctl/<namespace>/<container ID>/
However, currently they are not removed as shown below:
```
$ sudo nerdctl run -d --name nginx -p 81:80 nginx
ca1552d394cd8efcc5adcff9434deb4f3ead569d168f6e31bea1ae965db8b919
$ ls /run/nerdctl/default/ca1552d394cd8efcc5adcff9434deb4f3ead569d168f6e31bea1ae965db8b919
port-reserver.pid
$ sudo nerdctl rm -f nginx
nginx
$ ls /run/nerdctl/default/ca1552d394cd8efcc5adcff9434deb4f3ead569d168f6e31bea1ae965db8b919
port-reserver.pid
```
Therefore, this commit ensures that they are removed when the container is
removed.
Signed-off-by: Hayato Kiwata <dev@haytok.jp>1 parent d5bc0f0 commit b34858e
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
751 | 754 | | |
752 | 755 | | |
753 | 756 | | |
| |||
0 commit comments