Este contenido no está disponible en el idioma seleccionado.
Chapter 21. Using the container-tools API
Podman 2.0’s new REST-based API, replacing the old varlink remote API, offers both rootful and rootless support. It includes the Libpod API for Podman and a Docker-compatible API to call Podman from platforms like cURL, Postman, Google’s Advanced REST client, and others.
Since the Podman service relies on socket activation, it can not run unless connections are active. You need to manually start the podman.socket service to enable this feature. When a connection activates, the Podman service starts, executes the requested API action, then ends, returning to an inactive state.
21.1. Enabling the Podman API using systemd in root mode Copiar enlaceEnlace copiado en el portapapeles!
You can do the following:
-
Use
systemdto activate the Podman API socket. - Use a Podman client to perform basic commands.
Prerequisites
-
The
podman-remotepackage is installed.
Procedure
Start the service immediately:
systemctl enable --now podman.socket
# systemctl enable --now podman.socketCopy to Clipboard Copied! Toggle word wrap Toggle overflow To enable the link to
var/lib/docker.sockby using thedocker-podmanpackage:dnf install podman-docker
# dnf install podman-dockerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display system information of Podman:
podman-remote info
# podman-remote infoCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the link:
ls -al /var/run/docker.sock lrwxrwxrwx. 1 root root 23 Nov 4 10:19 /var/run/docker.sock -> /run/podman/podman.sock
# ls -al /var/run/docker.sock lrwxrwxrwx. 1 root root 23 Nov 4 10:19 /var/run/docker.sock -> /run/podman/podman.sockCopy to Clipboard Copied! Toggle word wrap Toggle overflow
21.2. Enabling the Podman API using systemd in rootless mode Copiar enlaceEnlace copiado en el portapapeles!
You can use systemd to activate the Podman API socket and podman API service.
Prerequisites
-
The
podman-remotepackage is installed.
Procedure
Enable and start the service immediately:
systemctl --user enable --now podman.socket
$ systemctl --user enable --now podman.socketCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: To enable programs by using Docker to interact with the rootless Podman socket:
export DOCKER_HOST=unix:///run/user/<uid>/podman//podman.sock
$ export DOCKER_HOST=unix:///run/user/<uid>/podman//podman.sockCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Check the status of the socket:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
podman.socketis active and is listening at/run/user/<uid>/podman.podman.sock, where<uid>is the user’s ID.Display system information of Podman:
podman-remote info
$ podman-remote infoCopy to Clipboard Copied! Toggle word wrap Toggle overflow
21.3. Running the Podman API manually Copiar enlaceEnlace copiado en el portapapeles!
You can run the Podman API. This is useful for debugging API calls, especially when using the Docker compatibility layer.
Prerequisites
-
The
podman-remotepackage is installed.
Procedure
Run the service for the REST API:
podman system service -t 0 --log-level=debug
# podman system service -t 0 --log-level=debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
The value of 0 means no timeout. The default endpoint for a rootful service is
unix:/run/podman/podman.sock. -
The
--log-level <level>option sets the logging level. The standard logging levels aredebug,info,warn,error,fatal, andpanic.
-
The value of 0 means no timeout. The default endpoint for a rootful service is
In another terminal, display system information of Podman. The
podman-remotecommand, unlike the regularpodmancommand, communicates through the Podman socket:podman-remote info
# podman-remote infoCopy to Clipboard Copied! Toggle word wrap Toggle overflow To troubleshoot the Podman API and display request and responses, use the
curlcomman. To get the information about the Podman installation on the Linux server in JSON format:Copy to Clipboard Copied! Toggle word wrap Toggle overflow A
jqutility is a command-line JSON processor.Pull the
registry.access.redhat.com/ubi10/ubicontainer image:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display the pulled image:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow