Skip to content

Add container inspect wrapper for podman 4 - #13

Open
afbjorklund wants to merge 1 commit into
brightzheng100:mainfrom
afbjorklund:inspect-podman
Open

Add container inspect wrapper for podman 4#13
afbjorklund wants to merge 1 commit into
brightzheng100:mainfrom
afbjorklund:inspect-podman

Conversation

@afbjorklund

@afbjorklund afbjorklund commented Mar 3, 2025

Copy link
Copy Markdown
Contributor

The inspect format differed in some types like StopSignal, making Unmarshal fail when using podman instead of docker.

Without this fix, podman breaks:
Error: json: cannot unmarshal number into Go struct field Config.Config.StopSignal of type string

With this fix, podman 4.9.3 works.

Using the docker pkg/signal (now in moby) and the podman pkg/signal helper functions, instead of importing all of libpod.

This is a NOOP, on other OS.

Since they can be updated*...

* That is, running a newer Podman 5 in the Podman Machine instead of the one that is available in the Linux distribution.

Closes #9


https://github.com/containers/podman/blob/v5.4.0/libpod/define/container_inspect.go#L111

https://github.com/containers/podman/blob/v5.4.0/pkg/signal/signal_common.go#L66

The inspect format differed in some types like StopSignal,
making Unmarshal fail when using podman instead of docker.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
@brightzheng100

Copy link
Copy Markdown
Owner

Just realized that you're also a contributor of Podman, which is cool.

I was a bit hesitant about whether I should have a dedicated package like pkg/podman so that I can handle differences between Docker and Podman: majority will be under pkg/docker while there will be more and more under pkg/podman along the evolving of Podman. Who knows!

What do you think?

@afbjorklund

Copy link
Copy Markdown
Contributor Author

I think it is fine to focus on Docker (only), and leave the compatibility to Podman and small workarounds (like this one)

But moving docker.InspectObject into pkg/docker sounds like it could be a good idea, to simplify pkg/cluster a bit?

@afbjorklund

afbjorklund commented Mar 16, 2025

Copy link
Copy Markdown
Contributor Author

Another (small) optimization could be to call docker container inspect, instead of searching through all objects.

i.e. docker inspect also has to look through images and what not (volumes, networks) to find an argument match

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make podman support explicit

2 participants