How to add Cockpit UI for Podman containers to NixOS
Introduction
Cockpit is a cutting-edge web-based graphical interface for server management. It allows you to administer servers effortlessly and includes a built-in terminal.
Personally, I utilize the NixOS package to monitor system logs, network settings, services, system resources, and CPU load and all without needing to touch the command line.
With the Cockpit UI for Podman containers, you can manage Podman containers directly in your browser. I thought it would be a useful addition to my NixOS server configuration. Although I won’t use it to create or update containers—I’ll handle that through the NixOS configuration—it’s convenient for quickly checking container statuses, viewing logs, and accessing the console.
How To
Unfortunately, Cockpit Podman is not available as a package. To resolve this, I added a custom package declaratively.
-
First create the
packages/cockpit
directoryRun the following command:
-
Create
/etc/nixos/packages/cockpit/default.nix
You can add
virtual-machines.nix
in the same way, but we will ignore that for now. -
Create
/etc/nixos/packages/cockpit/podman-containers.nix
The above is inspired by this script, but I modified it slightly to get it working again.
Adjust the version if necessary.
-
Add the
cockpit-apps
toconfiguration.nix
-
Switch NixOS configuration
Now you can switch to the new NixOS configuration. Run the following command:
-
Check the results
Now you can browse to Cockpit and the Podman container UI by opening a web browser and going to:
http://localhost:9090
. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.