Podman: Difference between revisions
enhance: headers |
Giantdwarf (talk | contribs) Updated podman compose documentation. I essentially copied the official documentation from https://docs.podman.io/en/stable/markdown/podman-compose.1.html and modified the instructions to use nixos options instead of manual file edits. |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 15: | Line 15: | ||
"podman" | "podman" | ||
]; | ]; | ||
}|name=/etc/nixos/configuration.nix|lang=nix}} | };|name=/etc/nixos/configuration.nix|lang=nix}} | ||
{{Security Warning|Beware that the podman group membership is effectively equivalent to being root, just like with Docker! <br> Consider using rootless podman.}} | |||
A reboot or re-login might be required for the permissions to take effect after applying changes | A reboot or re-login might be required for the permissions to take effect after applying changes | ||
== Tips and tricks == | == Tips and tricks == | ||
=== podman | === '''podman compose''' === | ||
podman compose is a thin wrapper around an external compose provider such as [https://github.com/docker/compose docker-compose] or [https://github.com/containers/podman-compose podman-compose]. This means that <code>podman compose</code> is executing another tool that implements the compose functionality but sets up the environment in a way to let the compose provider communicate transparently with the local Podman socket. The specified options as well as the command and argument are passed directly to the compose provider. | |||
The default compose providers are <code>docker-compose</code> and <code>podman-compose</code>. If installed, <code>docker-compose</code> takes precedence since it is the original implementation of the Compose specification. | |||
To change the default behavior or have a custom installation path for your provider of choice: <syntaxhighlight lang="nix">{ | |||
services.podman.settings.containers = { compose_providers = ["/path/to/provider"] }; | |||
}</syntaxhighlight>You may also set the <code>PODMAN_COMPOSE_PROVIDER</code> environment variable:<syntaxhighlight lang="bash">PODMAN_COMPOSE_PROVIDER="/path/to/provider" podman compose up -d</syntaxhighlight>or:<syntaxhighlight lang="nix">{ | |||
environment.sessionVariables = { | |||
PODMAN_COMPOSE_PROVIDER = "/path/to/provider"; | |||
}; | |||
}</syntaxhighlight>By default, <code>podman compose</code> will emit a warning saying that it executes an external command. This warning can be disabled by setting <code>compose_warning_logs</code> to false in <code>services.podman.settings.containers</code> or setting the <code>PODMAN_COMPOSE_WARNING_LOGS</code> environment variable to false.<syntaxhighlight lang="nix">{ | |||
services.podman.settings.containers = { | |||
compose_providers = ["/path/to/provider"]; | |||
compose_warning_logs = false; | |||
}; | |||
}</syntaxhighlight><syntaxhighlight lang="nix"> | |||
{ | |||
environment.sessionVariables = { | |||
PODMAN_COMPOSE_PROVIDER = "/path/to/provider"; | |||
PODMAN_COMPOSE_WARNING_LOGS = false; | |||
}; | |||
} | |||
</syntaxhighlight> | |||
=== With ZFS === | === With ZFS === | ||
| Line 120: | Line 143: | ||
To avoid this issue, you might restrict its registries configuration. | To avoid this issue, you might restrict its registries configuration. | ||
You can | You can change the global registries with:<syntaxhighlight lang="nix"> | ||
virtualisation.containers.registries.search = [ "docker.io" ]; | |||
</syntaxhighlight> | |||
For user-scoped registries you can do using [[Home Manager]] manually: | |||
# User-scoped `~/.config/containers/registries` | {{File|3=# User-scoped `~/.config/containers/registries` | ||
xdg.configFile."containers/registries.conf".text = '' | xdg.configFile."containers/registries.conf".text = '' | ||
[registries.search] | [registries.search] | ||