Difference between revisions of "NixOS Containers"

From NixOS Wiki
Jump to: navigation, search
Line 1: Line 1:
 
There's not much to read here. Look at {{manual:nixos|sec=#ch-containers|chapter=the upstream documentation on containers}} meanwhile.
 
There's not much to read here. Look at {{manual:nixos|sec=#ch-containers|chapter=the upstream documentation on containers}} meanwhile.
  
== Declarative docker contianers ==
+
== Declarative docker containers ==
  
 
Example config:
 
Example config:
Line 20: Line 20:
 
     };
 
     };
 
   }
 
   }
 
  
 
== Troubleshooting ==
 
== Troubleshooting ==

Revision as of 01:53, 28 October 2020

There's not much to read here. Look at NixOS Manual, the upstream documentation on containers meanwhile.

Declarative docker containers

Example config:

 { config, pkgs, ... }:
 {
   config.docker-containers = {
     hackagecompare = {
       image = "chrissound/hackagecomparestats-webserver:latest";
       ports = ["127.0.0.1:3010:3010"];
       volumes = [
         "/root/hackagecompare/packageStatistics.json:/root/hackagecompare/packageStatistics.json"
       ];
       cmd = [
         "--base-url"
         "\"/hackagecompare\""
       ];
     };
   };
 }

Troubleshooting

I have changed the host's channel and some services are no longer functional

Symptoms:

  • Lost data in PostgreSQL database
  • MySQL has changed its path, where it creates the database

Solution

If you did not have a system.stateVersion option set inside your declarative container configuration, it will use the default one for the channel. Your data might be safe, if you did nothing meanwhile. Add the missing system.stateVersion to your container, rebuild, and possibly stop/start the container.

See also

NixOS Manual, Chapter on Container Management