Watchtower On NixOS With Docker

There is no need for a long introduction here. This is the contents of my watchtower.nix file. Watchtower is a docker container that monitors all of your other docker containers for available updates, and then updates them automatically. Combining this with the Nix way of doing automated docker containers brings complete automation to your NixOS server. It's brilliant.

{ config, pkgs, ... }:


  # Watchtower
  virtualisation.oci-containers.containers."watchtower" = {
    autoStart = true;
    image = "containrrr/watchtower";
    volumes = [


Since that's in its own .nix file, we need to add it to the imports section of the /etc/nixos/configuration.nix, like so:

imports = [
  # Docker containers

That's it! Run sudo nixos-rebuild switch and, once it downloads and starts, you should have a running Watchtower container on your NixOS box!

My YouTube Channel

<< Articles