Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compatible events stream #2856

Open
mharwani opened this issue Mar 5, 2024 · 1 comment
Open

Docker compatible events stream #2856

mharwani opened this issue Mar 5, 2024 · 1 comment

Comments

@mharwani
Copy link

mharwani commented Mar 5, 2024

What is the problem you're trying to solve

I'd like to start the discussion on supporting Docker compatible events with nerdctl events command. The events stream returned by nerdctl is significantly different from docker events. Example, for a container start event:

$ nerdctl events --format '{{json .}}'
{"Timestamp":"2024-03-05T18:21:13.926302522Z","Namespace":"default","Topic":"/tasks/start","Event":"{\"container_id\":\"51885cadba61b9640f0ea80eb716b2f2e2bc60b42595db07bd8759e06b270fdb\",\"pid\":49760}"}
$ docker events --format '{{json .}}'
{"status":"start","id":"84f2374dda918b45b0d775409f17cbd2eb4ccf6f58b32b80493e9bac3bd240d2","from":"alpine","Type":"container","Action":"start","Actor":{"ID":"84f2374dda918b45b0d775409f17cbd2eb4ccf6f58b32b80493e9bac3bd240d2","Attributes":{"image":"alpine","name":"sweet_noyce"}},"scope":"local","time":1709663022,"timeNano":1709663022762686221}

Some of the events are not reported (eg: networking and volume related events) because they are not integrated with containerd. This breaks certain tools that rely on event notifications.

Describe the solution you'd like

I'd like to have a docker compatible option, or have it be the default mode:

$ nerdctl events --format '{{json .}}' --mode "dockercompat"

Additional context

The events command in nerdctl simply reports events emitted by containerd. However, I think as a CLI, nerdctl should have the ability to report its own events for features such as network and volume management. Additionally, having its own set of events would make it easier for nerdctl to output a Docker compatible events stream.

@mharwani
Copy link
Author

mharwani commented Mar 5, 2024

I have an approach in mind that I'd like to review with the community:

The CLI will publish all Docker compatible events to containerd with "dockercompat" topic prefix, eg: /dockercompat/container/start. Allows us to easily filter "dockercompat" and "native" events. Looking at the Docker API spec, there are certain events that cannot be published during CLI actions:

  • containers: destory, die, exec_die
  • networks: disconnect

These events are reported when a container process stops and exits. I think using an OCI-hook to publish them would be suitable here.

Let me know if you have suggestions. I'm happy to take this issue. Thanks!

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

No branches or pull requests

1 participant