Podman: Difference between revisions

From NixOS Wiki
imported>Fumesover
Removing `virtualisation.containers.users` since its deprecated
imported>Cyounkins
Replace "unstable" with "20.09", remove unneeded reference to the PR
Line 1: Line 1:
Podman can run rootless containers and be a drop-in replacement for Docker.
Podman can run rootless containers and be a drop-in replacement for Docker.


== Install and configure podman with NixOS service configuration (NixOS unstable) ==
== Install and configure podman with NixOS service configuration (NixOS >=20.09) ==
 
Since [https://github.com/NixOS/nixpkgs/pull/85604 PR 85604] using Podman is super simple:


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">

Revision as of 22:06, 25 June 2021

Podman can run rootless containers and be a drop-in replacement for Docker.

Install and configure podman with NixOS service configuration (NixOS >=20.09)

{ pkgs, ... }:
{
  virtualisation = {
    podman = {
      enable = true;

      # Create a `docker` alias for podman, to use it as a drop-in replacement
      dockerCompat = true;
    };
  };
}


Old manual configuration (NixOS <=20.03)

{ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [ podman runc conmon slirp4netns fuse-overlayfs ];
}

Configure subuid/subgid for your user

{
  users.users.username.subUidRanges = [{ startUid = 100000; count = 65536; }];
  users.users.username.subGidRanges = [{ startGid = 100000; count = 65536; }];
}

Create configuration files

{
  environment.etc."containers/policy.json" = {
    mode="0644";
    text=''
      {
        "default": [
          {
            "type": "insecureAcceptAnything"
          }
        ],
        "transports":
          {
            "docker-daemon":
              {
                "": [{"type":"insecureAcceptAnything"}]
              }
          }
      }
    '';
  };

  environment.etc."containers/registries.conf" = {
    mode="0644";
    text=''
      [registries.search]
      registries = ['docker.io', 'quay.io']
    '';
  };
}