Building and Running Docker Images with nix

Use nix to reliably and repeatedly build docker images.

{ pkgs ? import <nixpkgs> { system = "x86_64-linux"; } }:

pkgs.dockerTools.buildImage {
  name = "hello-docker";
  config = {
    Cmd = [ "${pkgs.hello}/bin/hello" ];
  };
}

Then run:

  1. nix-build hello-docer.nix
  2. docker load < result

Or:

  1. docker load < $(nix-build hello-docker.nix)

See docker tools for more notes or the manual for more information