@@ -231,14 +231,41 @@ rec {
231231 '';
232232 };
233233
234− # 14. Create another layered image, for comparing layers with image 10.
234+ # 14. Environment variable inheritance.
235+ # Child image should inherit parents environment variables,
236+ # optionally overriding them.
237+ environmentVariables = let
238+ parent = pkgs.dockerTools.buildImage {
239+ name = "parent";
240+ tag = "latest";
241+ config = {
242+ Env = [
243+ "FROM_PARENT=true"
244+ "LAST_LAYER=parent"
245+ ];
246+ };
247+ };
248+ in pkgs.dockerTools.buildImage {
249+ name = "child";
250+ fromImage = parent;
251+ tag = "latest";
252+ contents = [ pkgs.coreutils ];
253+ config = {
254+ Env = [
255+ "FROM_CHILD=true"
256+ "LAST_LAYER=child"
257+ ];
258+ };
259+ };
260+
261+ # 15. Create another layered image, for comparing layers with image 10.
235262 another-layered-image = pkgs.dockerTools.buildLayeredImage {
236263 name = "another-layered-image";
237264 tag = "latest";
238265 config.Cmd = [ "${pkgs.hello}/bin/hello" ];
239266 };
240267
241− # 15. Create a layered image with only 2 layers
268+ # 16. Create a layered image with only 2 layers
242269 two-layered-image = pkgs.dockerTools.buildLayeredImage {
243270 name = "two-layered-image";
244271 tag = "latest";
@@ -247,7 +274,7 @@ rec {
247274 maxLayers = 2;
248275 };
249276
250− # 16. Create a layered image with more packages than max layers.
277+ # 17. Create a layered image with more packages than max layers.
251278 # coreutils and hello are part of the same layer
252279 bulk-layer = pkgs.dockerTools.buildLayeredImage {
253280 name = "bulk-layer";
@@ -258,7 +285,7 @@ rec {
258285 maxLayers = 2;
259286 };
260287
261− # 17. Create a "layered" image without nix store layers. This is not
288+ # 18. Create a "layered" image without nix store layers. This is not
262289 # recommended, but can be useful for base images in rare cases.
263290 no-store-paths = pkgs.dockerTools.buildLayeredImage {
264291 name = "no-store-paths";