iac/nixos/modules/podman.nix
Sergei Poljanski a80134f6ff
Some checks failed
nixos / nixos (push) Failing after 1m45s
nixos: Podman DNS on every container network
The NixOS Podman module opens DNS (aardvark-dns, port 53) on podman0
only. CI jobs and compose stacks run on networks of their own, whose
bridges are podman1, podman2 and so on, so their containers could not
resolve anything. The first CI run on the converted asxpio-services
failed this way: nix could not reach cache.nixos.org. The rehearsal
jobs had not downloaded anything, so it went unnoticed there.

Open 53 on every podman* interface. Tried on the rehearsal host with a
container on its own network.

Assisted-by: Claude:opus-5-5
2026-11-17 07:12:52 +04:00

37 lines
1.4 KiB
Nix

# Containers, for what has no native NixOS service: Podman, no Docker
# daemon. Declared containers (virtualisation.oci-containers) become
# systemd units named podman-<name>.service.
#
# The `docker` command is the real Docker CLI (with compose and buildx)
# talking to rootful Podman's Docker-compatible socket, so the apps' CI
# deploys (`docker compose up -d`, `docker inspect`, `docker logs`) work
# unchanged, and root, deploy and the admins all see the same containers.
{ pkgs, ... }:
{
virtualisation.podman = {
enable = true;
dockerSocket.enable = true; # /run/docker.sock -> /run/podman/podman.sock
defaultNetwork.settings.dns_enabled = true;
# Every image update and CI job leaves an image behind
autoPrune = {
enable = true;
dates = "Mon 03:00";
flags = [ "--all" ];
};
};
virtualisation.oci-containers.backend = "podman";
environment.systemPackages = [ pkgs.docker-client ];
# Podman's DNS for container networks, on each bridge's gateway. The
# NixOS module opens it on podman0 only; CI jobs and compose stacks get
# networks of their own (podman1, podman2, ...).
networking.firewall.interfaces."podman*" = {
allowedUDPPorts = [ 53 ];
allowedTCPPorts = [ 53 ];
};
asxpio.security.ports = [
"tcp/53/aardvark-dns"
"udp/53/aardvark-dns"
];
environment.variables.DOCKER_HOST = "unix:///run/podman/podman.sock";
}