Generate Podman Quadlet files from a Podman command, compose file, or existing object
Generate Podman Quadlet files from a Podman command, compose file, or existing object
Podlet generates Podman Quadlet files from a Podman command, compose file, or existing object. Demo created with Autocast. You can also view the demo on asciinema.
podman runpodman pod createpodman kube playpodman network createpodman volume createpodman buildpodman image pullpodman artifact pull.container files..pod file and .container files..kube file and Kubernetes Pod YAML..quadlets file for use with podman quadlet install.--skip-services-check.--podman-version.--absolute-host-paths.The Podlet project shares communication channels with other projects in the Containers organization. On the Podman Discord, there are two dedicated channels for Podlet:
For discussions about issues, bugs, or features, feel free to create an issue, discussion, or pull request on GitHub.
Podlet can be acquired in several ways:
podman run ghcr.io/containers/podlet.cargo binstall podlet.cargo install podlet.brew install podlet…
See podlet --help for more information.
…
To generate a Quadlet file, just put podlet in front of your Podman command!
$ podlet podman run quay.io/podman/hello
# FileName=hello
[Container]
Image=quay.io/podman/hello
This is useful for more complicated commands you are copying. For example, let's create a Quadlet file for running Caddy. We'll also use a few options for additional sections in the file.
$ podlet --file . --install --description Caddy \
podman run \
--restart always \
-p 8000:80 \
-p 8443:443 \
-v ./Caddyfile:/etc/caddy/Caddyfile:Z \
-v caddy_data:/data \
docker.io/library/caddy:latest
Wrote to file: ./caddy.container
$ cat caddy.container
[Unit]
Description=Caddy
[Container]
Image=docker.io/library/caddy:latest
PublishPort=8000:80
PublishPort=8443:443
Volume=./Caddyfile:/etc/caddy/Caddyfile:Z
Volume=caddy_data:/data
[Service]
Restart=always
[Install]
WantedBy=default.target
The name for the file was automatically pulled from the image name, but can be overridden with the --name option.
Podlet also supports creating .pod, .kube, .network, .volume, .build, .image, and .artifact Quadlet files.
$ podlet podman kube play --network pasta --userns auto caddy.yaml
# FileName=caddy
[Kube]
Yaml=caddy.yaml
Network=pasta
UserNS=auto
Global Podman options are added to the GlobalArgs= Quadlet option.
$ podlet compose -h
Generate Podman Quadlet files from a compose file
Usage: podlet compose [OPTIONS] [COMPOSE_FILE]
Arguments:
[COMPOSE_FILE] The compose file to convert
Options:
--pod Create a `.pod` file and link it with each `.container` file
--kube Create a Kubernetes YAML file for a pod instead of separate containers
-h, --help Print help (see more with '--help')
Let's return to the Caddy example, say you have a compose file at compose-example.yaml:
name: caddy
services:
caddy:
image: docker.io/library/caddy:latest
ports:
- 8000:80
- 8443:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:Z
- caddy-data:/data
volumes:
caddy-data:
podlet compose compose-example.yaml will create a caddy.container file like so:
# FileName=caddy
[Container]
Image=docker.io/library/caddy:latest
PublishPort=8000:80
PublishPort=8443:443
Volume=./Caddyfile:/etc/caddy/Caddyfile:Z
Volume=caddy-data:/data
If a compose file is not given, Podlet will search for the following files in the current working directory, in order:
compose.yamlcompose.ymldocker-compose.yamldocker-compose.ymlpodman-compose.yamlpodman-compose.ymlThe --pod option will create a .pod Quadlet file and link each .container file to it.
$ podlet compose --pod compose-example.yaml
# FileName=caddy-caddy
[Container]
Image=docker.io/library/caddy:latest
Pod=caddy.pod
Volume=./Caddyfile:/etc/caddy/Caddyfile:Z
Volume=caddy-data:/data
---
# FileName=caddy
[Pod]
PublishPort=8000:80
PublishPort=8443:443
The --kube option will generate Kubernetes YAML which groups all compose services in a pod.
…
When converting Compose files, not all options are supported by Podman/Quadlet. This is especially true when converting to Kubernetes YAML as some options must be applied to the pod as a whole. If Podlet encounters an unsupported option an error will be returned. You will have to remove or comment out unsupported options to proceed.
Podlet does not yet support Compose interpolation.
See podlet compose --help for more information.
$ podlet generate -h
Generate a Podman Quadlet file from an existing object
Usage: podlet generate <COMMAND>
Commands:
container Generate a Quadlet file from an existing container
pod Generate Quadlet files from an existing pod and its containers
network Generate a Quadlet file from an existing network
volume Generate a Quadlet file from an existing volume
image Generate a Quadlet file from an image in local storage
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help (see more with '--help')
If you have an existing container, pod, network, volume, or image, you can use podlet generate to create a Quadlet file from it.
$ podman container create --name hello quay.io/podman/hello:latest
$ podlet generate container hello
# FileName=hello
[Container]
ContainerName=hello
Image=quay.io/podman/hello:latest
These commands require that podman is installed and searchable from the PATH environment variable.
See podlet generate --help for more information.
While Podlet can be used as-is in a container, passing the command to it; if you want to utilize some of the write-to-file functionality, or create Quadlet files from compose files, additional volumes may need to be attached.
An example of a generic Podman command that runs the most up-to-date version of Podlet with the current directory and user's Quadlet directory attached to the container would be:
podman run --rm --userns keep-id -e HOME -e XDG_CONFIG_HOME --user $(id -u) -v "$PWD":"$PWD" -v "$HOME/.config/containers/systemd/":"$HOME/.config/containers/systemd/" -w "$PWD" --security-opt label=disable --pull=newer ghcr.io/containers/podlet
Please note that --security-opt label=disable may be required for systems with SELinux. If your system does not use SELinux, the option is not needed. Podman recommends disabling SELinux separation when mounting system files and directories to containers. See the note at the end of the "Labeling Volume Mounts" section in the podman run --volume documentation.
Alternatively, if you just want Podlet to read a specific compose file you can use:
podman run --rm -v ./compose.yaml:/compose.yaml:Z ghcr.io/containers/podlet compose /compose.yaml
Podlet is primarily a tool for helping to get started with Podman systemd units, aka Quadlet files. It is not meant to be an end-all solution for creating and maintaining Quadlet files. Files created with Podlet should always be reviewed before starting the unit.
Podlet is not (yet) a validator for Podman commands. Some Podman options are incompatible with each other and most options require specific formatting and/or only accept certain values. However, a few options are fully parsed and validated in order to facilitate creating the Quadlet file.
Contributions, suggestions, and/or comments are appreciated! See the contribution guide for more information on reporting issues, submitting pull requests, building Podlet, the Minimum Supported Rust Version (MSRV) policy, and running CI tasks locally.
All source code for Podlet is licensed under the Mozilla Public License v2.0. View the LICENSE file for more information.
No open issues yet, or sync has not completed.