forked from mirrors/nixpkgs
dockerTools: Add example of using NixOS' etc
This commit is contained in:
parent
56c283e5c8
commit
9b2af8673b
|
@ -413,5 +413,10 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
|||
"docker rmi layered-image-with-path",
|
||||
)
|
||||
|
||||
with subtest("etc"):
|
||||
docker.succeed("${examples.etc} | docker load")
|
||||
docker.succeed("docker run --rm etc | grep localhost")
|
||||
docker.succeed("docker image rm etc:latest")
|
||||
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -559,6 +559,33 @@ rec {
|
|||
includeStorePaths = false;
|
||||
};
|
||||
|
||||
etc =
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
nixosCore = (lib.nixos.core ({ config, modules, ... }: {
|
||||
imports = [ pkgs.nixosModule modules.etc ];
|
||||
environment.etc."hosts" = {
|
||||
text = ''
|
||||
127.0.0.1 localhost
|
||||
::1 localhost
|
||||
'';
|
||||
mode = "0456";
|
||||
};
|
||||
}));
|
||||
in pkgs.dockerTools.streamLayeredImage {
|
||||
name = "etc";
|
||||
tag = "latest";
|
||||
enableFakechroot = true;
|
||||
fakeRootCommands = ''
|
||||
mkdir -p /etc
|
||||
${nixosCore.config.system.build.etcActivationCommands}
|
||||
'';
|
||||
config.Cmd = pkgs.writeScript "etc-cmd" ''
|
||||
#!${pkgs.busybox}/bin/sh
|
||||
${pkgs.busybox}/bin/cat /etc/hosts
|
||||
'';
|
||||
};
|
||||
|
||||
# Example export of the bash image
|
||||
exportBash = pkgs.dockerTools.exportImage { fromImage = bash; };
|
||||
|
||||
|
|
Loading…
Reference in a new issue