Skip to content

nerdctl stop should release rootless ports (OCI poststop event should be called on nerdctl stop) #458

Open

Description

@AkihiroSuda
$ nerdctl --version
nerdctl version 0.12.1-58-g757f823

$ nerdctl run -d --name nginx -p 8080:80 nginx:alpine
5debf438f4632aaf6346d022b8a98c89c36b03e729f21f5e3f89b718a370f2da

$ nerdctl stop nginx
nginx

$ lsof -i -P
COMMAND      PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
rootlessk 131938 suda   12u  IPv6 3543002      0t0  TCP *:8080 (LISTEN)

$ rootlessctl --socket /run/user/1001/containerd-rootless/api.sock list-ports
ID    PROTO    PARENTIP    PARENTPORT    CHILDIP    CHILDPORT    
7     tcp      0.0.0.0     8080                     8080  

The port should be released after nerdctl stop.

It looks like the OCI poststop event hook is not executed for nerdctl stop.

Activity

  1. added
    bug
    area/rootless
    on Oct 22, 2021
  2. changed the title [-]`nerdctl stop` should release rootless ports[/-] [+]`nerdctl stop` should release rootless ports (OCI `poststop` event should be called on `nerdctl stop`)[/+] on Oct 22, 2021
  3. junnplus commented on Dec 31, 2021

    @junnplus
  4. maruno commented on Oct 28, 2022

    @maruno

    A workaround for this issue when using nerdctl for development, if removing the container is okay in your usecase than using nerdctl run --rm will remove all traces of the container after running including the port.

  5. zhan9san commented on Nov 28, 2022

    @zhan9san
    Contributor

    It's against the definition of poststop.

    IMHO, the runtime-spec is for k8s pod, and there is no stop action in k8s pod.

  6. apostasie commented on Aug 25, 2024

    @apostasie
    Contributor

    @AkihiroSuda is this still something you think we should do?

    As @zhan9san pointed out, the spec for postStop states this is only triggered when about to destroy the container (not merely stopping it), and there is nothing in oci hooks for merely "stopping container".

    This is not an endorsement of oci-hooks btw - what I am asking is whether we want the feature (eg: release port on stop), regardless of implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/rootlessbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions