Podman: Difference between revisions

From NixOS Wiki
imported>Cyounkins
Replace "unstable" with "20.09", remove unneeded reference to the PR
imported>Mic92
remove 20.03 configuration (just upgrade...)
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 >=20.09) ==
== Install and configure podman with NixOS service configuration ==


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
Line 13: Line 13:
       dockerCompat = true;
       dockerCompat = true;
     };
     };
  };
}
</syntaxHighlight>
== Old manual configuration (NixOS <=20.03) ==
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [ podman runc conmon slirp4netns fuse-overlayfs ];
}
</syntaxHighlight>
=== Configure subuid/subgid for your user ===
<syntaxHighlight lang="nix">
{
  users.users.username.subUidRanges = [{ startUid = 100000; count = 65536; }];
  users.users.username.subGidRanges = [{ startGid = 100000; count = 65536; }];
}
</syntaxHighlight>
=== Create configuration files ===
<syntaxHighlight lang="nix">
{
  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']
    '';
   };
   };
}
}
</syntaxHighlight>
</syntaxHighlight>

Revision as of 07:05, 26 June 2021

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

Install and configure podman with NixOS service configuration

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

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