Created
December 4, 2018 17:39
-
-
Save grahamc/064f3b6f5e61ff2c4eee8f1521df20af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grahamc@Morbo> docker run --user 1000:1000 -it --rm layered-on-top:latest ~/projects/nixpkgs | |
total 36 | |
drwxr-xr-x 1 0 0 4096 Dec 4 17:39 . | |
drwxr-xr-x 1 0 0 4096 Dec 4 17:39 .. | |
-rwxr-xr-x 1 0 0 0 Dec 4 17:39 .dockerenv | |
dr-xr-xr-x 2 0 0 4096 Jan 1 1970 bin | |
drwxr-xr-x 5 0 0 360 Dec 4 17:39 dev | |
drwxr-xr-x 2 0 0 4096 Dec 4 17:39 etc | |
drwxrwxrwx 1 0 0 4096 Dec 4 17:39 example-output | |
dr-xr-xr-x 3 0 0 4096 Jan 1 1970 lib | |
dr-xr-xr-x 3 0 0 4096 Jan 1 1970 libexec | |
dr-xr-xr-x 1 0 0 4096 Jan 1 1970 nix | |
dr-xr-xr-x 249 0 0 0 Dec 4 17:39 proc | |
dr-xr-xr-x 5 0 0 4096 Jan 1 1970 share | |
dr-xr-xr-x 13 0 0 0 Dec 4 17:39 sys | |
total 12 | |
drwxrwxrwx 1 0 0 4096 Dec 4 17:39 . | |
drwxr-xr-x 1 0 0 4096 Dec 4 17:39 .. | |
drwxr-xr-x 2 1000 1000 4096 Dec 4 17:39 hi-there |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
# 10. Create a layered image | |
layered-image = pkgs.dockerTools.buildLayeredImage { | |
name = "layered-image"; | |
tag = "latest"; | |
config.Cmd = [ "${pkgs.hello}/bin/hello" ]; | |
contents = [ pkgs.hello pkgs.bash pkgs.coreutils ]; | |
}; | |
# 11. Create an image on top of a layered image | |
layered-on-top = pkgs.dockerTools.buildImage { | |
name = "layered-on-top"; | |
tag = "latest"; | |
fromImage = layered-image; | |
extraCommands = '' | |
mkdir ./example-output | |
chmod 777 ./example-output | |
''; | |
config.Cmd = [ "${pkgs.bash}/bin/bash" | |
"-c" "export PATH=${pkgs.coreutils}/bin/; mkdir /example-output/hi-there; ls -la /; ls -la /example-output"]; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment