skip to Main Content

How do I run a docker container declaratively on nixos server ? I am trying to run whoogle on a nix server and I don’t wish to manually restart the whoogle container everytime I restart the server.

2

Answers


  1. Chosen as BEST ANSWER

    After bit of guidance from the r/nixos community settled with this.

    { config, pkgs, ... }:
    
    let
      host = "mydomain";
    in
    {
      virtualisation = {
        podman = {
          enable = true;
          dockerCompat = true;
        };
        oci-containers = {
          backend = "podman";
          containers.whoogle-search = {
            image = "benbusby/whoogle-search";
            autoStart = true;
            ports = [ "8080:5000" ]; #server locahost : docker localhost
          };
        };
      };
      services.nginx.virtualHosts = {
        "search.${host}" = {
          enableACME = true;
          forceSSL = true;
          locations."/".proxyPass = "http://localhost:8080";
        };
      };
    }
    

    1. Use --restart always with docker command at initial start

    2. enable docker service to start at boot

    And your container will start at boot

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search