Crate podman_rest_client
source ·Expand description
Provides an interface for querying the Podman REST API. Most of the interface is generated from the the official Podman swagger file. This crate adds a layer to make it possible to connect to the podman rest api over ssh to a unix socket and directly to a unix socket. Connections over ssh are commonly necessary on macOs where the container runtime runs in a virtual machine accessible over ssh.
§API Compatibility
This crate currently only works with version 5 of the podman API. There are suffucient
differences between version 3, 4, and 5 that a lot of calls will not work in an older version.
podman --version
will reveal what version you are using.
§Podman Socket
Note that podman does not run in a client/server model like docker does so there usually isn’t a socket you can connect to by default. You would need to enable the socket for the library to connect to. For example on linux you might need to run something like this:
systemctl --user enable --now podman.socket
§Usage
use podman_rest_client::PodmanRestClient;
use podman_rest_client::Config;
let ssh_client = PodmanRestClient::new(Config {
uri: "ssh://core@127.0.0.1:63169/run/user/501/podman/podman.sock".to_string(),
identity_file: Some("/path/to/identity_file".into()),
}).await.unwrap();
let unix_client = PodmanRestClient::new(Config {
uri: "unix:///run/user/501/podman/podman.sock".to_string(),
identity_file: None,
}).await.unwrap();
You can also use Config::guess()
which tries to find the default path to the podman
socket depending on the platform you are on.
use podman_rest_client::PodmanRestClient;
use podman_rest_client::Config;
// Setup the default configuration
let config = Config::guess().await.unwrap();
// Initialize a client
let client = PodmanRestClient::new(config).await.unwrap();
// Fetch a list of container images
let images = client.images_api().image_list_libpod(None,None).await.unwrap();