docs/Nixpkgs/Build-Helpers/images/dockertools.section/index.html

3398 lines
159 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Aux Documentation">
<meta name="author" content="Nixpkgs Aux, and Lix Contributors">
<link rel="canonical" href="https://docs.auxolotl.org/Nixpkgs/Build-Helpers/images/dockertools.section/">
<link rel="prev" href="../binarycache.section/">
<link rel="next" href="../makediskimage.section/">
<link rel="icon" href="../../../../assets/aux-logo.svg">
<meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.29">
<title>pkgs.dockerTools - Aux Docs</title>
<link rel="stylesheet" href="../../../../assets/stylesheets/main.76a95c52.min.css">
<link rel="stylesheet" href="../../../../assets/stylesheets/palette.06af60db.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.bunny.net/css?family=IBM+Plex+Sans:300,300i,400,400i,700,700i%7CIBM+Plex+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"IBM Plex Sans";--md-code-font:"IBM Plex Mono"}</style>
<script>__md_scope=new URL("../../../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
<meta property="og:type" content="website" >
<meta property="og:title" content="pkgs.dockerTools {#sec-pkgs-dockerTools} - Aux Docs" >
<meta property="og:description" content="Aux Documentation" >
<meta property="og:image" content="https://docs.auxolotl.org/assets/images/social/Nixpkgs/Build-Helpers/images/dockertools.section.png" >
<meta property="og:image:type" content="image/png" >
<meta property="og:image:width" content="1200" >
<meta property="og:image:height" content="630" >
<meta property="og:url" content="https://docs.auxolotl.org/Nixpkgs/Build-Helpers/images/dockertools.section/" >
<meta name="twitter:card" content="summary_large_image" >
<meta name="twitter:title" content="pkgs.dockerTools {#sec-pkgs-dockerTools} - Aux Docs" >
<meta name="twitter:description" content="Aux Documentation" >
<meta name="twitter:image" content="https://docs.auxolotl.org/assets/images/social/Nixpkgs/Build-Helpers/images/dockertools.section.png" >
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="blue">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#sec-pkgs-dockerTools" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="../../../.." title="Aux Docs" class="md-header__button md-logo" aria-label="Aux Docs" data-md-component="logo">
<img src="../../../../assets/aux-logo.svg" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
Aux Docs
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
pkgs.dockerTools
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="blue" aria-label="Dark Mode" type="radio" name="__palette" id="__palette_0">
<label class="md-header__button md-icon" title="Dark Mode" for="__palette_1" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m17.75 4.09-2.53 1.94.91 3.06-2.63-1.81-2.63 1.81.91-3.06-2.53-1.94L12.44 4l1.06-3 1.06 3 3.19.09m3.5 6.91-1.64 1.25.59 1.98-1.7-1.17-1.7 1.17.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95 2.06.05m-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14.4-.4.82-.76 1.27-1.08.75-.53 1.93.36 1.85 1.19-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82-2.81 3.14-2.7 7.96.31 10.98 3.02 3.01 7.84 3.12 10.98.31Z"/></svg>
</label>
<input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="indigo" data-md-color-accent="blue" aria-label="Light Mode" type="radio" name="__palette" id="__palette_1">
<label class="md-header__button md-icon" title="Light Mode" for="__palette_0" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0-7 2.39 3.42C13.65 5.15 12.84 5 12 5c-.84 0-1.65.15-2.39.42L12 2M3.34 7l4.16-.35A7.2 7.2 0 0 0 5.94 8.5c-.44.74-.69 1.5-.83 2.29L3.34 7m.02 10 1.76-3.77a7.131 7.131 0 0 0 2.38 4.14L3.36 17M20.65 7l-1.77 3.79a7.023 7.023 0 0 0-2.38-4.15l4.15.36m-.01 10-4.14.36c.59-.51 1.12-1.14 1.54-1.86.42-.73.69-1.5.83-2.29L20.64 17M12 22l-2.41-3.44c.74.27 1.55.44 2.41.44.82 0 1.63-.17 2.37-.44L12 22Z"/></svg>
</label>
</form>
<script>var media,input,key,value,palette=__md_get("__palette");if(palette&&palette.color){"(prefers-color-scheme)"===palette.color.media&&(media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']"),palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent"));for([key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://git.auxolotl.org/auxolotl/docs" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16.777 0a2.9 2.9 0 1 1-2.529 4.322H12.91a4.266 4.266 0 0 0-4.265 4.195v2.118a7.076 7.076 0 0 1 4.147-1.42l.118-.002h1.338a2.9 2.9 0 0 1 5.43 1.422 2.9 2.9 0 0 1-5.43 1.422H12.91a4.266 4.266 0 0 0-4.265 4.195v2.319A2.9 2.9 0 0 1 7.222 24 2.9 2.9 0 0 1 5.8 18.57V8.589a7.109 7.109 0 0 1 6.991-7.108l.118-.001h1.338A2.9 2.9 0 0 1 16.778 0ZM7.223 19.905a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.389Zm9.554-10.464a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.39Zm0-7.735a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.389Z"/></svg>
</div>
<div class="md-source__repository">
auxolotl/docs
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs">
<div class="md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item">
<a href="../../../.." class="md-tabs__link">
Aux Documentation Hub
</a>
</li>
<li class="md-tabs__item">
<a href="../../../../TODO/" class="md-tabs__link">
TODO
</a>
</li>
<li class="md-tabs__item">
<a href="../../../../Aux/" class="md-tabs__link">
Aux
</a>
</li>
<li class="md-tabs__item">
<a href="../../../../Lix/" class="md-tabs__link">
Lix
</a>
</li>
<li class="md-tabs__item">
<a href="../../../../NixOS/appstream/" class="md-tabs__link">
NixOS
</a>
</li>
<li class="md-tabs__item md-tabs__item--active">
<a href="../../../" class="md-tabs__link">
Nixpkgs
</a>
</li>
</ul>
</div>
</nav>
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../../../.." title="Aux Docs" class="md-nav__button md-logo" aria-label="Aux Docs" data-md-component="logo">
<img src="../../../../assets/aux-logo.svg" alt="logo">
</a>
Aux Docs
</label>
<div class="md-nav__source">
<a href="https://git.auxolotl.org/auxolotl/docs" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16.777 0a2.9 2.9 0 1 1-2.529 4.322H12.91a4.266 4.266 0 0 0-4.265 4.195v2.118a7.076 7.076 0 0 1 4.147-1.42l.118-.002h1.338a2.9 2.9 0 0 1 5.43 1.422 2.9 2.9 0 0 1-5.43 1.422H12.91a4.266 4.266 0 0 0-4.265 4.195v2.319A2.9 2.9 0 0 1 7.222 24 2.9 2.9 0 0 1 5.8 18.57V8.589a7.109 7.109 0 0 1 6.991-7.108l.118-.001h1.338A2.9 2.9 0 0 1 16.778 0ZM7.223 19.905a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.389Zm9.554-10.464a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.39Zm0-7.735a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.389Z"/></svg>
</div>
<div class="md-source__repository">
auxolotl/docs
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../.." class="md-nav__link">
<span class="md-ellipsis">
Aux Documentation Hub
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../../TODO/" class="md-nav__link">
<span class="md-ellipsis">
TODO
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../../Aux/" class="md-nav__link">
<span class="md-ellipsis">
Aux
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../../Lix/" class="md-nav__link">
<span class="md-ellipsis">
Lix
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../../NixOS/appstream/" class="md-nav__link">
<span class="md-ellipsis">
NixOS
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" checked>
<div class="md-nav__link md-nav__container">
<a href="../../../" class="md-nav__link ">
<span class="md-ellipsis">
Nixpkgs
</span>
</a>
<label class="md-nav__link " for="__nav_6" id="__nav_6_label" tabindex="">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_6">
<span class="md-nav__icon md-icon"></span>
Nixpkgs
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../options/" class="md-nav__link">
<span class="md-ellipsis">
Options
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6_3" checked>
<div class="md-nav__link md-nav__container">
<a href="../../" class="md-nav__link ">
<span class="md-ellipsis">
Build Helpers
</span>
</a>
<label class="md-nav__link " for="__nav_6_3" id="__nav_6_3_label" tabindex="0">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_6_3_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_6_3">
<span class="md-nav__icon md-icon"></span>
Build Helpers
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../dev-shell-tools.chapter/" class="md-nav__link">
<span class="md-ellipsis">
Development Shell helpers
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../fetchers.chapter/" class="md-nav__link">
<span class="md-ellipsis">
Fetchers
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../" class="md-nav__link">
<span class="md-ellipsis">
Images
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../special/" class="md-nav__link">
<span class="md-ellipsis">
Special build helpers
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../testers.chapter/" class="md-nav__link">
<span class="md-ellipsis">
Testers
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../trivial-build-helpers.chapter/" class="md-nav__link">
<span class="md-ellipsis">
Trivial build helpers
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6_3_8" checked>
<label class="md-nav__link" for="__nav_6_3_8" id="__nav_6_3_8_label" tabindex="0">
<span class="md-ellipsis">
Images
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_6_3_8_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_6_3_8">
<span class="md-nav__icon md-icon"></span>
Images
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../appimagetools.section/" class="md-nav__link">
<span class="md-ellipsis">
pkgs.appimageTools
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../binarycache.section/" class="md-nav__link">
<span class="md-ellipsis">
pkgs.mkBinaryCache
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
pkgs.dockerTools
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
pkgs.dockerTools
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage" class="md-nav__link">
<span class="md-ellipsis">
buildImage
</span>
</a>
<nav class="md-nav" aria-label="buildImage">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage-inputs" class="md-nav__link">
<span class="md-ellipsis">
Inputs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage-passthru-outputs" class="md-nav__link">
<span class="md-ellipsis">
Passthru outputs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage-examples" class="md-nav__link">
<span class="md-ellipsis">
Examples
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../makediskimage.section/" class="md-nav__link">
<span class="md-ellipsis">
&lt;nixpkgs/nixos/lib/make-disk-image.nix&gt;
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../ocitools.section/" class="md-nav__link">
<span class="md-ellipsis">
pkgs.ociTools
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../portableservice.section/" class="md-nav__link">
<span class="md-ellipsis">
pkgs.portableService
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../special/checkpoint-build.section/" class="md-nav__link">
<span class="md-ellipsis">
Special
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Development/" class="md-nav__link">
<span class="md-ellipsis">
Development
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Functions/" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Hooks/" class="md-nav__link">
<span class="md-ellipsis">
Hooks
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Languages-And-Frameworks/" class="md-nav__link">
<span class="md-ellipsis">
Languages And Frameworks
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Library-Reference/asserts/" class="md-nav__link">
<span class="md-ellipsis">
Library Reference
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Module-System/module-system.chapter/" class="md-nav__link">
<span class="md-ellipsis">
Module System
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Packages/" class="md-nav__link">
<span class="md-ellipsis">
Packages
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Standard-Environment/" class="md-nav__link">
<span class="md-ellipsis">
Standard Environment
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
<li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
<a href="../../../Using-Nixpkgs/" class="md-nav__link">
<span class="md-ellipsis">
Using Nixpkgs
</span>
<span class="md-nav__icon md-icon"></span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage" class="md-nav__link">
<span class="md-ellipsis">
buildImage
</span>
</a>
<nav class="md-nav" aria-label="buildImage">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage-inputs" class="md-nav__link">
<span class="md-ellipsis">
Inputs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage-passthru-outputs" class="md-nav__link">
<span class="md-ellipsis">
Passthru outputs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#ssec-pkgs-dockerTools-buildImage-examples" class="md-nav__link">
<span class="md-ellipsis">
Examples
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1 id="sec-pkgs-dockerTools">pkgs.dockerTools</h1>
<p><code>pkgs.dockerTools</code> is a set of functions for creating and manipulating Docker images according to the <a href="https://github.com/moby/moby/blob/46f7ab808b9504d735d600e259ca0723f76fb164/image/spec/spec.md#image-json-field-descriptions">Docker Image Specification v1.3.0</a>.
Docker itself is not used to perform any of the operations done by these functions.</p>
<h2 id="ssec-pkgs-dockerTools-buildImage">buildImage</h2>
<p>This function builds a Docker-compatible repository tarball containing a single image.
As such, the result is suitable for being loaded in Docker with <code>docker image load</code> (see <a href="#ex-dockerTools-buildImage"></a> for how to do this).</p>
<p>This function will create a single layer for all files (and dependencies) that are specified in its argument.
Only new dependencies that are not already in the existing layers will be copied.
If you prefer to create multiple layers for the files and dependencies you want to add to the image, see <a href="#ssec-pkgs-dockerTools-buildLayeredImage"></a> or <a href="#ssec-pkgs-dockerTools-streamLayeredImage"></a> instead.</p>
<p>This function allows a script to be run during the layer generation process, allowing custom behaviour to affect the final results of the image (see the documentation of the <code>runAsRoot</code> and <code>extraCommands</code> attributes).</p>
<p>The resulting repository tarball will list a single image as specified by the <code>name</code> and <code>tag</code> attributes.
By default, that image will use a static creation date (see documentation for the <code>created</code> attribute).
This allows <code>buildImage</code> to produce reproducible images.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>When running an image built with <code>buildImage</code>, you might encounter certain errors depending on what you included in the image, especially if you did not start with any base image.</p>
</div>
<p>If you encounter errors similar to <code>getProtocolByName: does not exist (no such protocol name: tcp)</code>, you may need to add the contents of <code>pkgs.iana-etc</code> in the <code>copyToRoot</code> attribute.
Similarly, if you encounter errors similar to <code>Error_Protocol ("certificate has unknown CA",True,UnknownCa)</code>, you may need to add the contents of <code>pkgs.cacert</code> in the <code>copyToRoot</code> attribute.</p>
<h3 id="ssec-pkgs-dockerTools-buildImage-inputs">Inputs</h3>
<p><code>buildImage</code> expects an argument with the following attributes:</p>
<p><code>name</code> (String)</p>
<p>: The name of the generated image.</p>
<p><code>tag</code> (String or Null; <em>optional</em>)</p>
<p>: Tag of the generated image.
If <code>null</code>, the hash of the nix derivation will be used as the tag.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>fromImage</code> (Path or Null; <em>optional</em>)</p>
<p>: The repository tarball of an image to be used as the base for the generated image.
It must be a valid Docker image, such as one exported by <code>docker image save</code>, or another image built with the <code>dockerTools</code> utility functions.
This can be seen as an equivalent of <code>FROM fromImage</code> in a <code>Dockerfile</code>.
A value of <code>null</code> can be seen as an equivalent of <code>FROM scratch</code>.</p>
<p>If specified, the layer created by <code>buildImage</code> will be appended to the layers defined in the base image, resulting in an image with at least two layers (one or more layers from the base image, and the layer created by <code>buildImage</code>).
Otherwise, the resulting image with contain the single layer created by <code>buildImage</code>.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>fromImageName</code> (String or Null; <em>optional</em>)</p>
<p>: Used to specify the image within the repository tarball in case it contains multiple images.
A value of <code>null</code> means that <code>buildImage</code> will use the first image available in the repository.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This must be used with <code>fromImageTag</code>. Using only <code>fromImageName</code> without <code>fromImageTag</code> will make <code>buildImage</code> use the first image available in the repository.</p>
</div>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>fromImageTag</code> (String or Null; <em>optional</em>)</p>
<p>: Used to specify the image within the repository tarball in case it contains multiple images.
A value of <code>null</code> means that <code>buildImage</code> will use the first image available in the repository.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This must be used with <code>fromImageName</code>. Using only <code>fromImageTag</code> without <code>fromImageName</code> will make <code>buildImage</code> use the first image available in the repository</p>
</div>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>copyToRoot</code> (Path, List of Paths, or Null; <em>optional</em>)</p>
<p>: Files to add to the generated image.
Anything that coerces to a path (e.g. a derivation) can also be used.
This can be seen as an equivalent of <code>ADD contents/ /</code> in a <code>Dockerfile</code>.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>keepContentsDirlinks</code> (Boolean; <em>optional</em>)</p>
<p>: When adding files to the generated image (as specified by <code>copyToRoot</code>), this attribute controls whether to preserve symlinks to directories.
If <code>false</code>, the symlinks will be transformed into directories.
This behaves the same as <code>rsync -k</code> when <code>keepContentsDirlinks</code> is <code>false</code>, and the same as <code>rsync -K</code> when <code>keepContentsDirlinks</code> is <code>true</code>.</p>
<p><em>Default value:</em> <code>false</code>.</p>
<p><code>runAsRoot</code> (String or Null; <em>optional</em>)</p>
<p>: A bash script that will run as root inside a VM that contains the existing layers of the base image and the new generated layer (including the files from <code>copyToRoot</code>).
The script will be run with a working directory of <code>/</code>.
This can be seen as an equivalent of <code>RUN ...</code> in a <code>Dockerfile</code>.
A value of <code>null</code> means that this step in the image generation process will be skipped.</p>
<p>See <a href="#ex-dockerTools-buildImage-runAsRoot"></a> for how to work with this attribute.</p>
<p>{.caution}
Using this attribute requires the <code>kvm</code> device to be available, see <a href="https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-system-features"><code>system-features</code></a>.
If the <code>kvm</code> device isn't available, you should consider using <a href="#ssec-pkgs-dockerTools-buildLayeredImage"><code>buildLayeredImage</code></a> or <a href="#ssec-pkgs-dockerTools-streamLayeredImage"><code>streamLayeredImage</code></a> instead.
Those functions allow scripts to be run as root without access to the <code>kvm</code> device.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>At the time the script in <code>runAsRoot</code> is run, the files specified directly in <code>copyToRoot</code> will be present in the VM, but their dependencies might not be there yet.
Copying their dependencies into the generated image is a step that happens after <code>runAsRoot</code> finishes running.</p>
</div>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>extraCommands</code> (String; <em>optional</em>)</p>
<p>: A bash script that will run before the layer created by <code>buildImage</code> is finalised.
The script will be run on some (opaque) working directory which will become <code>/</code> once the layer is created.
This is similar to <code>runAsRoot</code>, but the script specified in <code>extraCommands</code> is <strong>not</strong> run as root, and does not involve creating a VM.
It is simply run as part of building the derivation that outputs the layer created by <code>buildImage</code>.</p>
<p>See <a href="#ex-dockerTools-buildImage-extraCommands"></a> for how to work with this attribute, and subtle differences compared to <code>runAsRoot</code>.</p>
<p><em>Default value:</em> <code>""</code>.</p>
<p><code>config</code> (Attribute Set or Null; <em>optional</em>)</p>
<p>: Used to specify the configuration of the containers that will be started off the generated image.
Must be an attribute set, with each attribute as listed in the <a href="https://github.com/moby/moby/blob/46f7ab808b9504d735d600e259ca0723f76fb164/image/spec/spec.md#image-json-field-descriptions">Docker Image Specification v1.3.0</a>.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>architecture</code> (String; <em>optional</em>)</p>
<p>: Used to specify the image architecture.
This is useful for multi-architecture builds that don't need cross compiling.
If specified, its value should follow the <a href="https://github.com/opencontainers/image-spec/blob/main/config.md#properties">OCI Image Configuration Specification</a>, which should still be compatible with Docker.
According to the linked specification, all possible values for <code>$GOARCH</code> in <a href="https://go.dev/doc/install/source#environment">the Go docs</a> should be valid, but will commonly be one of <code>386</code>, <code>amd64</code>, <code>arm</code>, or <code>arm64</code>.</p>
<p><em>Default value:</em> the same value from <code>pkgs.go.GOARCH</code>.</p>
<p><code>diskSize</code> (Number; <em>optional</em>)</p>
<p>: Controls the disk size (in megabytes) of the VM used to run the script specified in <code>runAsRoot</code>.
This attribute is ignored if <code>runAsRoot</code> is <code>null</code>.</p>
<p><em>Default value:</em> 1024.</p>
<p><code>buildVMMemorySize</code> (Number; <em>optional</em>)</p>
<p>: Controls the amount of memory (in megabytes) provisioned for the VM used to run the script specified in <code>runAsRoot</code>.
This attribute is ignored if <code>runAsRoot</code> is <code>null</code>.</p>
<p><em>Default value:</em> 512.</p>
<p><code>created</code> (String; <em>optional</em>)</p>
<p>: Specifies the time of creation of the generated image.
This should be either a date and time formatted according to <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> or <code>"now"</code>, in which case <code>buildImage</code> will use the current date.</p>
<p>See <a href="#ex-dockerTools-buildImage-creatednow"></a> for how to use <code>"now"</code>.</p>
<p>{.caution}
Using <code>"now"</code> means that the generated image will not be reproducible anymore (because the date will always change whenever it's built).</p>
<p><em>Default value:</em> <code>"1970-01-01T00:00:01Z"</code>.</p>
<p><code>uid</code> (Number; <em>optional</em>)</p>
<p>: The uid of the user that will own the files packed in the new layer built by <code>buildImage</code>.</p>
<p><em>Default value:</em> 0.</p>
<p><code>gid</code> (Number; <em>optional</em>)</p>
<p>: The gid of the group that will own the files packed in the new layer built by <code>buildImage</code>.</p>
<p><em>Default value:</em> 0.</p>
<p><code>compressor</code> (String; <em>optional</em>)</p>
<p>: Selects the algorithm used to compress the image.</p>
<p><em>Default value:</em> <code>"gz"</code>.\
<em>Possible values:</em> <code>"none"</code>, <code>"gz"</code>, <code>"zstd"</code>.</p>
<p><code>contents</code> <strong>DEPRECATED</strong></p>
<p>: This attribute is deprecated, and users are encouraged to use <code>copyToRoot</code> instead.</p>
<h3 id="ssec-pkgs-dockerTools-buildImage-passthru-outputs">Passthru outputs</h3>
<p><code>buildImage</code> defines a few <a href="#chap-passthru"><code>passthru</code></a> attributes:</p>
<p><code>buildArgs</code> (Attribute Set)</p>
<p>: The argument passed to <code>buildImage</code> itself.
This allows you to inspect all attributes specified in the argument, as described above.</p>
<p><code>layer</code> (Attribute Set)</p>
<p>: The derivation with the layer created by <code>buildImage</code>.
This allows easier inspection of the contents added by <code>buildImage</code> in the generated image.</p>
<p><code>imageTag</code> (String)</p>
<p>: The tag of the generated image.
This is useful if no tag was specified in the attributes of the argument to <code>buildImage</code>, because an automatic tag will be used instead.
<code>imageTag</code> allows you to retrieve the value of the tag used in this case.</p>
<h3 id="ssec-pkgs-dockerTools-buildImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Building a Docker image
</code></pre></div>
<p>The following package builds a Docker image that runs the <code>redis-server</code> executable from the <code>redis</code> package.
The Docker image will have name <code>redis</code> and tag <code>latest</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> buildEnv<span class="p">,</span> redis <span class="p">}:</span>
dockerTools<span class="o">.</span>buildImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;redis&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">copyToRoot</span> <span class="o">=</span> buildEnv <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;image-root&quot;</span><span class="p">;</span>
<span class="ss">paths</span> <span class="o">=</span> <span class="p">[</span> redis <span class="p">];</span>
<span class="ss">pathsToLink</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin&quot;</span> <span class="p">];</span>
<span class="p">};</span>
<span class="ss">runAsRoot</span> <span class="o">=</span> <span class="s s-Multiline">&#39;&#39;</span>
<span class="s s-Multiline"> mkdir -p /data</span>
<span class="s s-Multiline"> &#39;&#39;</span><span class="p">;</span>
<span class="ss">config</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/redis-server&quot;</span> <span class="p">];</span>
<span class="ss">WorkingDir</span> <span class="o">=</span> <span class="s2">&quot;/data&quot;</span><span class="p">;</span>
<span class="ss">Volumes</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">&quot;/data&quot;</span> <span class="o">=</span> <span class="p">{</span> <span class="p">};</span> <span class="p">};</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a <code>.tar.gz</code> file that can be loaded into Docker:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
building<span class="w"> </span><span class="s1">&#39;/nix/store/yw0adm4wpsw1w6j4fb5hy25b3arr9s1v-docker-image-redis.tar.gz.drv&#39;</span>...
Adding<span class="w"> </span>layer...
tar:<span class="w"> </span>Removing<span class="w"> </span>leading<span class="w"> </span><span class="sb">`</span>/<span class="err">&#39;</span><span class="w"> </span>from<span class="w"> </span>member<span class="w"> </span>names
Adding<span class="w"> </span>meta...
Cooking<span class="w"> </span>the<span class="w"> </span>image...
Finished.
/nix/store/p4dsg62inh9d2ksy3c7bv58xa851dasr-docker-image-redis.tar.gz
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load<span class="w"> </span>-i<span class="w"> </span>/nix/store/p4dsg62inh9d2ksy3c7bv58xa851dasr-docker-image-redis.tar.gz
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>redis:latest
</code></pre></div>
</div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="building-a-docker-image-with-runasroot">Building a Docker image with <code>runAsRoot</code></h1>
</div>
<p>The following package builds a Docker image with the <code>hello</code> executable from the <code>hello</code> package.
It uses <code>runAsRoot</code> to create a directory and a file inside the image.</p>
<p>This works the same as <a href="#ex-dockerTools-buildImage-extraCommands"></a>, but uses <code>runAsRoot</code> instead of <code>extraCommands</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> buildEnv<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">copyToRoot</span> <span class="o">=</span> buildEnv <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;image-root&quot;</span><span class="p">;</span>
<span class="ss">paths</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="ss">pathsToLink</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin&quot;</span> <span class="p">];</span>
<span class="p">};</span>
<span class="ss">runAsRoot</span> <span class="o">=</span> <span class="s s-Multiline">&#39;&#39;</span>
<span class="s s-Multiline"> mkdir -p /data</span>
<span class="s s-Multiline"> echo &quot;some content&quot; &gt; my-file</span>
<span class="s s-Multiline"> &#39;&#39;</span><span class="p">;</span>
<span class="ss">config</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="ss">WorkingDir</span> <span class="o">=</span> <span class="s2">&quot;/data&quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="building-a-docker-image-with-extracommands">Building a Docker image with <code>extraCommands</code></h1>
</div>
<p>The following package builds a Docker image with the <code>hello</code> executable from the <code>hello</code> package.
It uses <code>extraCommands</code> to create a directory and a file inside the image.</p>
<p>This works the same as <a href="#ex-dockerTools-buildImage-runAsRoot"></a>, but uses <code>extraCommands</code> instead of <code>runAsRoot</code>.
Note that with <code>extraCommands</code>, we can't directly reference <code>/</code> and must create files and directories as if we were already on <code>/</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> buildEnv<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">copyToRoot</span> <span class="o">=</span> buildEnv <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;image-root&quot;</span><span class="p">;</span>
<span class="ss">paths</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="ss">pathsToLink</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin&quot;</span> <span class="p">];</span>
<span class="p">};</span>
<span class="ss">extraCommands</span> <span class="o">=</span> <span class="s s-Multiline">&#39;&#39;</span>
<span class="s s-Multiline"> mkdir -p data</span>
<span class="s s-Multiline"> echo &quot;some content&quot; &gt; my-file</span>
<span class="s s-Multiline"> &#39;&#39;</span><span class="p">;</span>
<span class="ss">config</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="ss">WorkingDir</span> <span class="o">=</span> <span class="s2">&quot;/data&quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="building-a-docker-image-with-a-creation-date-set-to-the-current-time">Building a Docker image with a creation date set to the current time</h1>
</div>
<p>Note that using a value of <code>"now"</code> in the <code>created</code> attribute will break reproducibility.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> buildEnv<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">created</span> <span class="o">=</span> <span class="s2">&quot;now&quot;</span><span class="p">;</span>
<span class="ss">copyToRoot</span> <span class="o">=</span> buildEnv <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;image-root&quot;</span><span class="p">;</span>
<span class="ss">paths</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="ss">pathsToLink</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin&quot;</span> <span class="p">];</span>
<span class="p">};</span>
config<span class="o">.</span><span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="p">}</span>
</code></pre></div>
<p>After importing the generated repository tarball with Docker, its CLI will display a reasonable date and sort the images as expected:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>ls
REPOSITORY<span class="w"> </span>TAG<span class="w"> </span>IMAGE<span class="w"> </span>ID<span class="w"> </span>CREATED<span class="w"> </span>SIZE
hello<span class="w"> </span>latest<span class="w"> </span>de2bf4786de6<span class="w"> </span>About<span class="w"> </span>a<span class="w"> </span>minute<span class="w"> </span>ago<span class="w"> </span><span class="m">25</span>.2MB
</code></pre></div>
<h2 id="ssec-pkgs-dockerTools-buildLayeredImage">buildLayeredImage</h2>
<p><code>buildLayeredImage</code> uses <a href="#ssec-pkgs-dockerTools-streamLayeredImage"><code>streamLayeredImage</code></a> underneath to build a compressed Docker-compatible repository tarball.
Basically, <code>buildLayeredImage</code> runs the script created by <code>streamLayeredImage</code> to save the compressed image in the Nix store.
<code>buildLayeredImage</code> supports the same options as <code>streamLayeredImage</code>, see <a href="#ssec-pkgs-dockerTools-streamLayeredImage"><code>streamLayeredImage</code></a> for details.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Despite the similar name, <a href="#ssec-pkgs-dockerTools-buildImage"><code>buildImage</code></a> works completely differently from <code>buildLayeredImage</code> and <code>streamLayeredImage</code>.</p>
</div>
<p>Even though some of the arguments may seem related, they cannot be interchanged.</p>
<p>You can load the result of this function in Docker with <code>docker image load</code>.
See <a href="#ex-dockerTools-buildLayeredImage-hello"></a> to see how to do that.</p>
<h3 id="ssec-pkgs-dockerTools-buildLayeredImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Building a layered Docker image
</code></pre></div>
<p>The following package builds a layered Docker image that runs the <code>hello</code> executable from the <code>hello</code> package.
The Docker image will have name <code>hello</code> and tag <code>latest</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
config<span class="o">.</span><span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a <code>.tar.gz</code> file that can be loaded into Docker:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
building<span class="w"> </span><span class="s1">&#39;/nix/store/bk8bnrbw10nq7p8pvcmdr0qf57y6scha-hello.tar.gz.drv&#39;</span>...
No<span class="w"> </span><span class="s1">&#39;fromImage&#39;</span><span class="w"> </span>provided
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">1</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/i93s7xxblavsacpy82zdbn4kplsyq48l-libunistring-1.1&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">2</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/ji01n9vinnj22nbrb86nx8a1ssgpilx8-libidn2-2.3.4&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">3</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/ldrslljw4rg026nw06gyrdwl78k77vyq-xgcc-12.3.0-libgcc&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">4</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/9y8pmvk8gdwwznmkzxa6pwyah52xy3nk-glibc-2.38-27&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">5</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">6</span><span class="w"> </span>with<span class="w"> </span>customisation...
Adding<span class="w"> </span>manifests...
Done.
/nix/store/hxcz7snvw7f8rzhbh6mv8jq39d992905-hello.tar.gz
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load<span class="w"> </span>-i<span class="w"> </span>/nix/store/hxcz7snvw7f8rzhbh6mv8jq39d992905-hello.tar.gz
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>hello:latest
</code></pre></div>
</div>
<h2 id="ssec-pkgs-dockerTools-streamLayeredImage">streamLayeredImage</h2>
<p><code>streamLayeredImage</code> builds a <strong>script</strong> which, when run, will stream to stdout a Docker-compatible repository tarball containing a single image, using multiple layers to improve sharing between images.
This means that <code>streamLayeredImage</code> does not output an image into the Nix store, but only a script that builds the image, saving on IO and disk/cache space, particularly with large images.</p>
<p>You can load the result of this function in Docker with <code>docker image load</code>.
See <a href="#ex-dockerTools-streamLayeredImage-hello"></a> to see how to do that.</p>
<p>For this function, you specify a <a href="https://nixos.org/manual/nix/stable/store/store-path">store path</a> or a list of store paths to be added to the image, and the functions will automatically include any dependencies of those paths in the image.
The function will attempt to create one layer per object in the Nix store that needs to be added to the image.
In case there are more objects to include than available layers, the function will put the most <a href="https://github.com/NixOS/nixpkgs/tree/release-23.11/pkgs/build-support/references-by-popularity">"popular"</a> objects in their own layers, and group all remaining objects into a single layer.</p>
<p>An additional layer will be created with symlinks to the store paths you specified to be included in the image.
These symlinks are built with <a href="#trivial-builder-symlinkJoin"><code>symlinkJoin</code></a>, so they will be included in the root of the image.
See <a href="#ex-dockerTools-streamLayeredImage-exploringlayers"></a> to understand how these symlinks are laid out in the generated image.</p>
<p><code>streamLayeredImage</code> allows scripts to be run when creating the additional layer with symlinks, allowing custom behaviour to affect the final results of the image (see the documentation of the <code>extraCommands</code> and <code>fakeRootCommands</code> attributes).</p>
<p>The resulting repository tarball will list a single image as specified by the <code>name</code> and <code>tag</code> attributes.
By default, that image will use a static creation date (see documentation for the <code>created</code> attribute).
This allows the function to produce reproducible images.</p>
<h3 id="ssec-pkgs-dockerTools-streamLayeredImage-inputs">Inputs</h3>
<p><code>streamLayeredImage</code> expects one argument with the following attributes:</p>
<p><code>name</code> (String)</p>
<p>: The name of the generated image.</p>
<p><code>tag</code> (String or Null; <em>optional</em>)</p>
<p>: Tag of the generated image.
If <code>null</code>, the hash of the nix derivation will be used as the tag.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>fromImage</code>(Path or Null; <em>optional</em>)</p>
<p>: The repository tarball of an image to be used as the base for the generated image.
It must be a valid Docker image, such as one exported by <code>docker image save</code>, or another image built with the <code>dockerTools</code> utility functions.
This can be seen as an equivalent of <code>FROM fromImage</code> in a <code>Dockerfile</code>.
A value of <code>null</code> can be seen as an equivalent of <code>FROM scratch</code>.</p>
<p>If specified, the created layers will be appended to the layers defined in the base image.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>contents</code> (Path or List of Paths; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-contents}</p>
<p>: Directories whose contents will be added to the generated image.
Things that coerce to paths (e.g. a derivation) can also be used.
This can be seen as an equivalent of <code>ADD contents/ /</code> in a <code>Dockerfile</code>.</p>
<p>All the contents specified by <code>contents</code> will be added as a final layer in the generated image.
They will be added as links to the actual files (e.g. links to the store paths).
The actual files will be added in previous layers.</p>
<p><em>Default value:</em> <code>[]</code></p>
<p><code>config</code> (Attribute Set or Null; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-config}</p>
<p>: Used to specify the configuration of the containers that will be started off the generated image.
Must be an attribute set, with each attribute as listed in the <a href="https://github.com/moby/moby/blob/46f7ab808b9504d735d600e259ca0723f76fb164/image/spec/spec.md#image-json-field-descriptions">Docker Image Specification v1.3.0</a>.</p>
<p>If any packages are used directly in <code>config</code>, they will be automatically included in the generated image.
See <a href="#ex-dockerTools-streamLayeredImage-configclosure"></a> for an example.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>architecture</code> (String; <em>optional</em>)</p>
<p>: Used to specify the image architecture.
This is useful for multi-architecture builds that don't need cross compiling.
If specified, its value should follow the <a href="https://github.com/opencontainers/image-spec/blob/main/config.md#properties">OCI Image Configuration Specification</a>, which should still be compatible with Docker.
According to the linked specification, all possible values for <code>$GOARCH</code> in <a href="https://go.dev/doc/install/source#environment">the Go docs</a> should be valid, but will commonly be one of <code>386</code>, <code>amd64</code>, <code>arm</code>, or <code>arm64</code>.</p>
<p><em>Default value:</em> the same value from <code>pkgs.go.GOARCH</code>.</p>
<p><code>created</code> (String; <em>optional</em>)</p>
<p>: Specifies the time of creation of the generated image.
This should be either a date and time formatted according to <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> or <code>"now"</code>, in which case the current date will be used.</p>
<p>{.caution}
Using <code>"now"</code> means that the generated image will not be reproducible anymore (because the date will always change whenever it's built).</p>
<p><em>Default value:</em> <code>"1970-01-01T00:00:01Z"</code>.</p>
<p><code>uid</code> (Number; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-uid}
<code>gid</code> (Number; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-gid}
<code>uname</code> (String; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-uname}
<code>gname</code> (String; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-gname}</p>
<p>: Credentials for Nix store ownership.
Can be overridden to e.g. <code>1000</code> / <code>1000</code> / <code>"user"</code> / <code>"user"</code> to enable building a container where Nix can be used as an unprivileged user in single-user mode.</p>
<p><em>Default value:</em> <code>0</code> / <code>0</code> / <code>"root"</code> / <code>"root"</code></p>
<p><code>maxLayers</code> (Number; <em>optional</em>) []{#dockerTools-buildLayeredImage-arg-maxLayers}</p>
<p>: The maximum number of layers that will be used by the generated image.
If a <code>fromImage</code> was specified, the number of layers used by <code>fromImage</code> will be subtracted from <code>maxLayers</code> to ensure that the image generated will have at most <code>maxLayers</code>.</p>
<p>{.caution}
Depending on the tool/runtime where the image will be used, there might be a limit to the number of layers that an image can have.
For Docker, see <a href="https://github.com/docker/docs/issues/8230">this issue on GitHub</a>.</p>
<p><em>Default value:</em> 100.</p>
<p><code>extraCommands</code> (String; <em>optional</em>)</p>
<p>: A bash script that will run in the context of the layer created with the contents specified by <code>contents</code>.
At the moment this script runs, only the contents directly specified by <code>contents</code> will be available as links.</p>
<p><em>Default value:</em> <code>""</code>.</p>
<p><code>fakeRootCommands</code> (String; <em>optional</em>)</p>
<p>: A bash script that will run in the context of the layer created with the contents specified by <code>contents</code>.
During the process to generate that layer, the script in <code>extraCommands</code> will be run first, if specified.
After that, a {manpage}<code>fakeroot(1)</code> environment will be entered.
The script specified in <code>fakeRootCommands</code> runs inside the fakeroot environment, and the layer is then generated from the view of the files inside the fakeroot environment.</p>
<p>This is useful to change the owners of the files in the layer (by running <code>chown</code>, for example), or performing any other privileged operations related to file manipulation (by default, all files in the layer will be owned by root, and the build environment doesn't have enough privileges to directly perform privileged operations on these files).</p>
<p>For more details, see the manpage for {manpage}<code>fakeroot(1)</code>.</p>
<p>{.caution}
Due to how fakeroot works, static binaries cannot perform privileged file operations in <code>fakeRootCommands</code>, unless <code>enableFakechroot</code> is set to <code>true</code>.</p>
<p><em>Default value:</em> <code>""</code>.</p>
<p><code>enableFakechroot</code> (Boolean; <em>optional</em>)</p>
<p>: By default, the script specified in <code>fakeRootCommands</code> only runs inside a fakeroot environment.
If <code>enableFakechroot</code> is <code>true</code>, a more complete chroot environment will be created using <a href="https://proot-me.github.io/"><code>proot</code></a> before running the script in <code>fakeRootCommands</code>.
Files in the Nix store will be available.
This allows scripts that perform installation in <code>/</code> to work as expected.
This can be seen as an equivalent of <code>RUN ...</code> in a <code>Dockerfile</code>.</p>
<p><em>Default value:</em> <code>false</code></p>
<p><code>includeStorePaths</code> (Boolean; <em>optional</em>)</p>
<p>: The files specified in <code>contents</code> are put into layers in the generated image.
If <code>includeStorePaths</code> is <code>false</code>, the actual files will not be included in the generated image, and only links to them will be added instead.
It is <strong>not recommended</strong> to set this to <code>false</code> unless you have other tooling to insert the store paths via other means (such as bind mounting the host store) when running containers with the generated image.
If you don't provide any extra tooling, the generated image won't run properly.</p>
<p>See <a href="#ex-dockerTools-streamLayeredImage-exploringlayers"></a> to understand the impact of setting <code>includeStorePaths</code> to <code>false</code>.</p>
<p><em>Default value:</em> <code>true</code></p>
<p><code>passthru</code> (Attribute Set; <em>optional</em>)</p>
<p>: Use this to pass any attributes as <a href="#chap-passthru"><code>passthru</code></a> for the resulting derivation.</p>
<p><em>Default value:</em> <code>{}</code></p>
<h3 id="ssec-pkgs-dockerTools-streamLayeredImage-passthru-outputs">Passthru outputs</h3>
<p><code>streamLayeredImage</code> also defines its own <a href="#chap-passthru"><code>passthru</code></a> attributes:</p>
<p><code>imageTag</code> (String)</p>
<p>: The tag of the generated image.
This is useful if no tag was specified in the attributes of the argument to the function, because an automatic tag will be used instead.
<code>imageTag</code> allows you to retrieve the value of the tag used in this case.</p>
<h3 id="ssec-pkgs-dockerTools-streamLayeredImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Streaming a layered Docker image
</code></pre></div>
<p>The following package builds a <strong>script</strong> which, when run, will stream a layered Docker image that runs the <code>hello</code> executable from the <code>hello</code> package.
The Docker image will have name <code>hello</code> and tag <code>latest</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>streamLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
config<span class="o">.</span><span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a script.
Running this script and piping it into <code>docker image load</code> gives you the same image that was built in <a href="#ex-dockerTools-buildLayeredImage-hello"></a>.
Note that in this case, the image is never added to the Nix store, but instead streamed directly into Docker.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/wsz2xl8ckxnlb769irvq6jv1280dfvxd-stream-hello
$<span class="w"> </span>/nix/store/wsz2xl8ckxnlb769irvq6jv1280dfvxd-stream-hello<span class="w"> </span><span class="p">|</span><span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load
No<span class="w"> </span><span class="s1">&#39;fromImage&#39;</span><span class="w"> </span>provided
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">1</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/i93s7xxblavsacpy82zdbn4kplsyq48l-libunistring-1.1&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">2</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/ji01n9vinnj22nbrb86nx8a1ssgpilx8-libidn2-2.3.4&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">3</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/ldrslljw4rg026nw06gyrdwl78k77vyq-xgcc-12.3.0-libgcc&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">4</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/9y8pmvk8gdwwznmkzxa6pwyah52xy3nk-glibc-2.38-27&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">5</span><span class="w"> </span>from<span class="w"> </span>paths:<span class="w"> </span><span class="o">[</span><span class="s1">&#39;/nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1&#39;</span><span class="o">]</span>
Creating<span class="w"> </span>layer<span class="w"> </span><span class="m">6</span><span class="w"> </span>with<span class="w"> </span>customisation...
Adding<span class="w"> </span>manifests...
Done.
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>hello:latest
</code></pre></div>
</div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="exploring-the-layers-in-an-image-built-with-streamlayeredimage">Exploring the layers in an image built with <code>streamLayeredImage</code></h1>
</div>
<p>Assume the following package, which builds a layered Docker image with the <code>hello</code> package.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>streamLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="p">}</span>
</code></pre></div>
<p>The <code>hello</code> package depends on 4 other packages:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-store<span class="w"> </span>--query<span class="w"> </span>-R<span class="w"> </span><span class="k">$(</span>nix-build<span class="w"> </span>-A<span class="w"> </span>hello<span class="k">)</span>
/nix/store/i93s7xxblavsacpy82zdbn4kplsyq48l-libunistring-1.1
/nix/store/ji01n9vinnj22nbrb86nx8a1ssgpilx8-libidn2-2.3.4
/nix/store/ldrslljw4rg026nw06gyrdwl78k77vyq-xgcc-12.3.0-libgcc
/nix/store/9y8pmvk8gdwwznmkzxa6pwyah52xy3nk-glibc-2.38-27
/nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1
</code></pre></div>
<p>This means that all these packages will be included in the image generated by <code>streamLayeredImage</code>.
It will put each package in its own layer, for a total of 5 layers with actual files in them.
A final layer will be created only with symlinks for the <code>hello</code> package.</p>
<p>The image generated will have the following directory structure (some directories were collapsed for readability):</p>
<div class="highlight"><pre><span></span><code>├── bin
│ └── hello → /nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1/bin/hello
├── nix
│ └── store
│ ├─⊕ 9y8pmvk8gdwwznmkzxa6pwyah52xy3nk-glibc-2.38-27
│ ├─⊕ i93s7xxblavsacpy82zdbn4kplsyq48l-libunistring-1.1
│ ├─⊕ ji01n9vinnj22nbrb86nx8a1ssgpilx8-libidn2-2.3.4
│ ├─⊕ ldrslljw4rg026nw06gyrdwl78k77vyq-xgcc-12.3.0-libgcc
│ └─⊕ zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1
└── share
├── info
│ └── hello.info → /nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1/share/info/hello.info
├─⊕ locale
└── man
└── man1
└── hello.1.gz → /nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1/share/man/man1/hello.1.gz
</code></pre></div>
<p>Each of the packages in <code>/nix/store</code> comes from a layer in the image.
The final layer adds the <code>/bin</code> and <code>/share</code> directories, but they only contain links to the actual files in <code>/nix/store</code>.</p>
<p>If our package sets <code>includeStorePaths</code> to <code>false</code>, we'll end up with only the final layer with the links, but the actual files won't exist in the image:</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>streamLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="ss">includeStorePaths</span> <span class="o">=</span> <span class="no">false</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
<p>After building this package, the image will have the following directory structure:</p>
<div class="highlight"><pre><span></span><code>├── bin
│ └── hello → /nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1/bin/hello
└── share
├── info
│ └── hello.info → /nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1/share/info/hello.info
├─⊕ locale
└── man
└── man1
└── hello.1.gz → /nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1/share/man/man1/hello.1.gz
</code></pre></div>
<p>Note how the links point to paths in <code>/nix/store</code>, but they're not included in the image itself.
This is why you need extra tooling when using <code>includeStorePaths</code>:
a container created from such image won't find any of the files it needs to run otherwise.</p>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="building-a-layered-docker-image-with-packages-directly-in-config">Building a layered Docker image with packages directly in <code>config</code></h1>
</div>
<p>The closure of <code>config</code> is automatically included in the generated image.
The following package shows a more compact way to create the same output generated in <a href="#ex-dockerTools-streamLayeredImage-hello"></a>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello<span class="p">,</span> lib <span class="p">}:</span>
dockerTools<span class="o">.</span>streamLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
config<span class="o">.</span><span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;</span><span class="si">${</span>lib<span class="o">.</span>getExe hello<span class="si">}</span><span class="s2">&quot;</span> <span class="p">];</span>
<span class="p">}</span>
</code></pre></div>
<p>[]{#ssec-pkgs-dockerTools-fetchFromRegistry}</p>
<h2 id="ssec-pkgs-dockerTools-pullImage">pullImage</h2>
<p>This function is similar to the <code>docker image pull</code> command, which means it can be used to pull a Docker image from a registry that implements the <a href="https://distribution.github.io/distribution/spec/api/">Docker Registry HTTP API V2</a>.
By default, the <code>docker.io</code> registry is used.</p>
<p>The image will be downloaded as an uncompressed Docker-compatible repository tarball, which is suitable for use with other <code>dockerTools</code> functions such as <a href="#ssec-pkgs-dockerTools-buildImage"><code>buildImage</code></a>, <a href="#ssec-pkgs-dockerTools-buildLayeredImage"><code>buildLayeredImage</code></a>, and <a href="#ssec-pkgs-dockerTools-streamLayeredImage"><code>streamLayeredImage</code></a>.</p>
<p>This function requires two different types of hashes/digests to be specified:</p>
<ul>
<li>One of them is used to identify a unique image within the registry (see the documentation for the <code>imageDigest</code> attribute).</li>
<li>The other is used by Nix to ensure the contents of the output haven't changed (see the documentation for the <code>sha256</code> attribute).</li>
</ul>
<p>Both hashes are required because they must uniquely identify some content in two completely different systems (the Docker registry and the Nix store), but their values will not be the same.
See <a href="#ex-dockerTools-pullImage-nixprefetchdocker"></a> for a tool that can help gather these values.</p>
<h3 id="ssec-pkgs-dockerTools-pullImage-inputs">Inputs</h3>
<p><code>pullImage</code> expects a single argument with the following attributes:</p>
<p><code>imageName</code> (String)</p>
<p>: Specifies the name of the image to be downloaded, as well as the registry endpoint.
By default, the <code>docker.io</code> registry is used.
To specify a different registry, prepend the endpoint to <code>imageName</code>, separated by a slash (<code>/</code>).
See <a href="#ex-dockerTools-pullImage-differentregistry"></a> for how to do that.</p>
<p><code>imageDigest</code> (String)</p>
<p>: Specifies the digest of the image to be downloaded.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p><strong>Why can't I specify a tag to pull from, and have to use a digest instead?</strong></p>
</div>
<p>Tags are often updated to point to different image contents.
The most common example is the <code>latest</code> tag, which is usually updated whenever a newer image version is available.</p>
<p>An image tag isn't enough to guarantee the contents of an image won't change, but a digest guarantees this.
Providing a digest helps ensure that you will still be able to build the same Nix code and get the same output even if newer versions of an image are released.</p>
<p><code>sha256</code> (String)</p>
<p>: The hash of the image after it is downloaded.
Internally, this is passed to the <a href="https://nixos.org/manual/nix/stable/language/advanced-attributes#adv-attr-outputHash"><code>outputHash</code></a> attribute of the resulting derivation.
This is needed to provide a guarantee to Nix that the contents of the image haven't changed, because Nix doesn't support the value in <code>imageDigest</code>.</p>
<p><code>finalImageName</code> (String; <em>optional</em>)</p>
<p>: Specifies the name that will be used for the image after it has been downloaded.
This only applies after the image is downloaded, and is not used to identify the image to be downloaded in the registry.
Use <code>imageName</code> for that instead.</p>
<p><em>Default value:</em> the same value specified in <code>imageName</code>.</p>
<p><code>finalImageTag</code> (String; <em>optional</em>)</p>
<p>: Specifies the tag that will be used for the image after it has been downloaded.
This only applies after the image is downloaded, and is not used to identify the image to be downloaded in the registry.</p>
<p><em>Default value:</em> <code>"latest"</code>.</p>
<p><code>os</code> (String; <em>optional</em>)</p>
<p>: Specifies the operating system of the image to pull.
If specified, its value should follow the <a href="https://github.com/opencontainers/image-spec/blob/main/config.md#properties">OCI Image Configuration Specification</a>, which should still be compatible with Docker.
According to the linked specification, all possible values for <code>$GOOS</code> in <a href="https://go.dev/doc/install/source#environment">the Go docs</a> should be valid, but will commonly be one of <code>darwin</code> or <code>linux</code>.</p>
<p><em>Default value:</em> <code>"linux"</code>.</p>
<p><code>arch</code> (String; <em>optional</em>)</p>
<p>: Specifies the architecture of the image to pull.
If specified, its value should follow the <a href="https://github.com/opencontainers/image-spec/blob/main/config.md#properties">OCI Image Configuration Specification</a>, which should still be compatible with Docker.
According to the linked specification, all possible values for <code>$GOARCH</code> in <a href="https://go.dev/doc/install/source#environment">the Go docs</a> should be valid, but will commonly be one of <code>386</code>, <code>amd64</code>, <code>arm</code>, or <code>arm64</code>.</p>
<p><em>Default value:</em> the same value from <code>pkgs.go.GOARCH</code>.</p>
<p><code>tlsVerify</code> (Boolean; <em>optional</em>)</p>
<p>: Used to enable or disable HTTPS and TLS certificate verification when communicating with the chosen Docker registry.
Setting this to <code>false</code> will make <code>pullImage</code> connect to the registry through HTTP.</p>
<p><em>Default value:</em> <code>true</code>.</p>
<p><code>name</code> (String; <em>optional</em>)</p>
<p>: The name used for the output in the Nix store path.</p>
<p><em>Default value:</em> a value derived from <code>finalImageName</code> and <code>finalImageTag</code>, with some symbols replaced.
It is recommended to treat the default as an opaque value.</p>
<h3 id="ssec-pkgs-dockerTools-pullImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Pulling the nixos/nix Docker image from the default registry
</code></pre></div>
<p>This example pulls the <a href="https://hub.docker.com/r/nixos/nix"><code>nixos/nix</code> image</a> and saves it in the Nix store.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools <span class="p">}:</span>
dockerTools<span class="o">.</span>pullImage <span class="p">{</span>
<span class="ss">imageName</span> <span class="o">=</span> <span class="s2">&quot;nixos/nix&quot;</span><span class="p">;</span>
<span class="ss">imageDigest</span> <span class="o">=</span> <span class="s2">&quot;sha256:b8ea88f763f33dfda2317b55eeda3b1a4006692ee29e60ee54ccf6d07348c598&quot;</span><span class="p">;</span>
<span class="ss">finalImageName</span> <span class="o">=</span> <span class="s2">&quot;nix&quot;</span><span class="p">;</span>
<span class="ss">finalImageTag</span> <span class="o">=</span> <span class="s2">&quot;2.19.3&quot;</span><span class="p">;</span>
<span class="ss">sha256</span> <span class="o">=</span> <span class="s2">&quot;zRwlQs1FiKrvHPaf8vWOR/Tlp1C5eLn1d9pE4BZg3oA=&quot;</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
</div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="pulling-the-nixosnix-docker-image-from-a-specific-registry">Pulling the nixos/nix Docker image from a specific registry</h1>
</div>
<p>This example pulls the <a href="https://quay.io/repository/coreos/etcd"><code>coreos/etcd</code> image</a> from the <code>quay.io</code> registry.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools <span class="p">}:</span>
dockerTools<span class="o">.</span>pullImage <span class="p">{</span>
<span class="ss">imageName</span> <span class="o">=</span> <span class="s2">&quot;quay.io/coreos/etcd&quot;</span><span class="p">;</span>
<span class="ss">imageDigest</span> <span class="o">=</span> <span class="s2">&quot;sha256:24a23053f29266fb2731ebea27f915bb0fb2ae1ea87d42d890fe4e44f2e27c5d&quot;</span><span class="p">;</span>
<span class="ss">finalImageName</span> <span class="o">=</span> <span class="s2">&quot;etcd&quot;</span><span class="p">;</span>
<span class="ss">finalImageTag</span> <span class="o">=</span> <span class="s2">&quot;v3.5.11&quot;</span><span class="p">;</span>
<span class="ss">sha256</span> <span class="o">=</span> <span class="s2">&quot;Myw+85f2/EVRyMB3axECdmQ5eh9p1q77FWYKy8YpRWU=&quot;</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="finding-the-digest-and-hash-values-to-use-for-dockertoolspullimage">Finding the digest and hash values to use for <code>dockerTools.pullImage</code></h1>
</div>
<p>Since <a href="#ssec-pkgs-dockerTools-pullImage"><code>dockerTools.pullImage</code></a> requires two different hashes, one can run the <code>nix-prefetch-docker</code> tool to find out the values for the hashes.
The tool outputs some text for an attribute set which you can pass directly to <code>pullImage</code>.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix<span class="w"> </span>run<span class="w"> </span>nixpkgs#nix-prefetch-docker<span class="w"> </span>--<span class="w"> </span>--image-name<span class="w"> </span>nixos/nix<span class="w"> </span>--image-tag<span class="w"> </span><span class="m">2</span>.19.3<span class="w"> </span>--arch<span class="w"> </span>amd64<span class="w"> </span>--os<span class="w"> </span>linux
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Writing<span class="w"> </span>manifest<span class="w"> </span>to<span class="w"> </span>image<span class="w"> </span>destination
-&gt;<span class="w"> </span>ImageName:<span class="w"> </span>nixos/nix
-&gt;<span class="w"> </span>ImageDigest:<span class="w"> </span>sha256:498fa2d7f2b5cb3891a4edf20f3a8f8496e70865099ba72540494cd3e2942634
-&gt;<span class="w"> </span>FinalImageName:<span class="w"> </span>nixos/nix
-&gt;<span class="w"> </span>FinalImageTag:<span class="w"> </span>latest
-&gt;<span class="w"> </span>ImagePath:<span class="w"> </span>/nix/store/4mxy9mn6978zkvlc670g5703nijsqc95-docker-image-nixos-nix-latest.tar
-&gt;<span class="w"> </span>ImageHash:<span class="w"> </span>1q6cf2pdrasa34zz0jw7pbs6lvv52rq2aibgxccbwcagwkg2qj1q
<span class="o">{</span>
<span class="w"> </span><span class="nv">imageName</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;nixos/nix&quot;</span><span class="p">;</span>
<span class="w"> </span><span class="nv">imageDigest</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;sha256:498fa2d7f2b5cb3891a4edf20f3a8f8496e70865099ba72540494cd3e2942634&quot;</span><span class="p">;</span>
<span class="w"> </span><span class="nv">sha256</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;1q6cf2pdrasa34zz0jw7pbs6lvv52rq2aibgxccbwcagwkg2qj1q&quot;</span><span class="p">;</span>
<span class="w"> </span><span class="nv">finalImageName</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;nixos/nix&quot;</span><span class="p">;</span>
<span class="w"> </span><span class="nv">finalImageTag</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="o">}</span>
</code></pre></div>
<p>It is important to supply the <code>--arch</code> and <code>--os</code> arguments to <code>nix-prefetch-docker</code> to filter to a single image, in case there are multiple architectures and/or operating systems supported by the image name and tags specified.
By default, <code>nix-prefetch-docker</code> will set <code>os</code> to <code>linux</code> and <code>arch</code> to <code>amd64</code>.</p>
<p>Run <code>nix-prefetch-docker --help</code> for a list of all supported arguments:
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix<span class="w"> </span>run<span class="w"> </span>nixpkgs#nix-prefetch-docker<span class="w"> </span>--<span class="w"> </span>--help
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
</code></pre></div></p>
<h2 id="ssec-pkgs-dockerTools-exportImage">exportImage</h2>
<p>This function is similar to the <code>docker container export</code> command, which means it can be used to export an image's filesystem as an uncompressed tarball archive.
The difference is that <code>docker container export</code> is applied to containers, but <code>dockerTools.exportImage</code> applies to Docker images.
The resulting archive will not contain any image metadata (such as command to run with <code>docker container run</code>), only the filesystem contents.</p>
<p>You can use this function to import an archive in Docker with <code>docker image import</code>.
See <a href="#ex-dockerTools-exportImage-importingDocker"></a> to understand how to do that.</p>
<p>{.caution}
<code>exportImage</code> works by unpacking the given image inside a VM.
Because of this, using this function requires the <code>kvm</code> device to be available, see <a href="https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-system-features"><code>system-features</code></a>.</p>
<h3 id="ssec-pkgs-dockerTools-exportImage-inputs">Inputs</h3>
<p><code>exportImage</code> expects an argument with the following attributes:</p>
<p><code>fromImage</code> (Attribute Set or String)</p>
<p>: The repository tarball of the image whose filesystem will be exported.
It must be a valid Docker image, such as one exported by <code>docker image save</code>, or another image built with the <code>dockerTools</code> utility functions.</p>
<p>If <code>name</code> is not specified, <code>fromImage</code> must be an Attribute Set corresponding to a derivation, i.e. it can't be a path to a tarball.
If <code>name</code> is specified, <code>fromImage</code> can be either an Attribute Set corresponding to a derivation or simply a path to a tarball.</p>
<p>See <a href="#ex-dockerTools-exportImage-naming"></a> and <a href="#ex-dockerTools-exportImage-fromImagePath"></a> to understand the connection between <code>fromImage</code>, <code>name</code>, and the name used for the output of <code>exportImage</code>.</p>
<p><code>fromImageName</code> (String or Null; <em>optional</em>)</p>
<p>: Used to specify the image within the repository tarball in case it contains multiple images.
A value of <code>null</code> means that <code>exportImage</code> will use the first image available in the repository.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This must be used with <code>fromImageTag</code>. Using only <code>fromImageName</code> without <code>fromImageTag</code> will make <code>exportImage</code> use the first image available in the repository.</p>
</div>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>fromImageTag</code> (String or Null; <em>optional</em>)</p>
<p>: Used to specify the image within the repository tarball in case it contains multiple images.
A value of <code>null</code> means that <code>exportImage</code> will use the first image available in the repository.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This must be used with <code>fromImageName</code>. Using only <code>fromImageTag</code> without <code>fromImageName</code> will make <code>exportImage</code> use the first image available in the repository</p>
</div>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>diskSize</code> (Number; <em>optional</em>)</p>
<p>: Controls the disk size (in megabytes) of the VM used to unpack the image.</p>
<p><em>Default value:</em> 1024.</p>
<p><code>name</code> (String; <em>optional</em>)</p>
<p>: The name used for the output in the Nix store path.</p>
<p><em>Default value:</em> the value of <code>fromImage.name</code>.</p>
<h3 id="ssec-pkgs-dockerTools-exportImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Exporting a Docker image with `dockerTools.exportImage`
</code></pre></div>
<p>This example first builds a layered image with <a href="#ssec-pkgs-dockerTools-buildLayeredImage"><code>dockerTools.buildLayeredImage</code></a>, and then exports its filesystem with <code>dockerTools.exportImage</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>exportImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">fromImage</span> <span class="o">=</span> dockerTools<span class="o">.</span>buildLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<p>When building the package above, we can see the layers of the Docker image being unpacked to produce the final output:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Unpacking<span class="w"> </span>base<span class="w"> </span>image...
From-image<span class="w"> </span>name<span class="w"> </span>or<span class="w"> </span>tag<span class="w"> </span>wasn<span class="s1">&#39;t set. Reading the first ID.</span>
<span class="s1">Unpacking layer 5731199219418f175d1580dbca05677e69144425b2d9ecb60f416cd57ca3ca42/layer.tar</span>
<span class="s1">tar: Removing leading `/&#39;</span><span class="w"> </span>from<span class="w"> </span>member<span class="w"> </span>names
Unpacking<span class="w"> </span>layer<span class="w"> </span>e2897bf34bb78c4a65736510204282d9f7ca258ba048c183d665bd0f3d24c5ec/layer.tar
tar:<span class="w"> </span>Removing<span class="w"> </span>leading<span class="w"> </span><span class="sb">`</span>/<span class="s1">&#39; from member names</span>
<span class="s1">Unpacking layer 420aa5876dca4128cd5256da7dea0948e30ef5971712f82601718cdb0a6b4cda/layer.tar</span>
<span class="s1">tar: Removing leading `/&#39;</span><span class="w"> </span>from<span class="w"> </span>member<span class="w"> </span>names
Unpacking<span class="w"> </span>layer<span class="w"> </span>ea5f4e620e7906c8ecbc506b5e6f46420e68d4b842c3303260d5eb621b5942e5/layer.tar
tar:<span class="w"> </span>Removing<span class="w"> </span>leading<span class="w"> </span><span class="sb">`</span>/<span class="s1">&#39; from member names</span>
<span class="s1">Unpacking layer 65807b9abe8ab753fa97da8fb74a21fcd4725cc51e1b679c7973c97acd47ebcf/layer.tar</span>
<span class="s1">tar: Removing leading `/&#39;</span><span class="w"> </span>from<span class="w"> </span>member<span class="w"> </span>names
Unpacking<span class="w"> </span>layer<span class="w"> </span>b7da2076b60ebc0ea6824ef641978332b8ac908d47b2d07ff31b9cc362245605/layer.tar
Executing<span class="w"> </span>post-mount<span class="w"> </span>steps...
Packing<span class="w"> </span>raw<span class="w"> </span>image...
<span class="o">[</span><span class="w"> </span><span class="m">1</span>.660036<span class="o">]</span><span class="w"> </span>reboot:<span class="w"> </span>Power<span class="w"> </span>down
/nix/store/x6a5m7c6zdpqz1d8j7cnzpx9glzzvd2h-hello
</code></pre></div>
<p>The following command lists some of the contents of the output to verify that the structure of the archive is as expected:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>tar<span class="w"> </span>--exclude<span class="w"> </span><span class="s1">&#39;*/share/*&#39;</span><span class="w"> </span>--exclude<span class="w"> </span><span class="s1">&#39;nix/store/*/*&#39;</span><span class="w"> </span>-tvf<span class="w"> </span>/nix/store/x6a5m7c6zdpqz1d8j7cnzpx9glzzvd2h-hello
drwxr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./
drwxr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./bin/
lrwxrwxrwx<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./bin/hello<span class="w"> </span>-&gt;<span class="w"> </span>/nix/store/h92a9jd0lhhniv2q417hpwszd4jhys7q-hello-2.12.1/bin/hello
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/store/
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/store/05zbwhz8a7i2v79r9j21pl6m6cj0xi8k-libunistring-1.1/
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/store/ayg5rhjhi9ic73hqw33mjqjxwv59ndym-xgcc-13.2.0-libgcc/
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/store/h92a9jd0lhhniv2q417hpwszd4jhys7q-hello-2.12.1/
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/store/m59xdgkgnjbk8kk6k6vbxmqnf82mk9s0-libidn2-2.3.4/
dr-xr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./nix/store/p3jshbwxiwifm1py0yq544fmdyy98j8a-glibc-2.38-27/
drwxr-xr-x<span class="w"> </span>root/0<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="m">1979</span>-12-31<span class="w"> </span><span class="m">16</span>:00<span class="w"> </span>./share/
</code></pre></div>
</div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="importing-an-archive-built-with-dockertoolsexportimage-in-docker">Importing an archive built with <code>dockerTools.exportImage</code> in Docker</h1>
</div>
<p>We will use the same package from <a href="#ex-dockerTools-exportImage-hello"></a> and import it into Docker.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>exportImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">fromImage</span> <span class="o">=</span> dockerTools<span class="o">.</span>buildLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<p>Building and importing it into Docker:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/x6a5m7c6zdpqz1d8j7cnzpx9glzzvd2h-hello
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>import<span class="w"> </span>/nix/store/x6a5m7c6zdpqz1d8j7cnzpx9glzzvd2h-hello
sha256:1d42dba415e9b298ea0decf6497fbce954de9b4fcb2984f91e307c8fedc1f52f
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>ls
REPOSITORY<span class="w"> </span>TAG<span class="w"> </span>IMAGE<span class="w"> </span>ID<span class="w"> </span>CREATED<span class="w"> </span>SIZE
&lt;none&gt;<span class="w"> </span>&lt;none&gt;<span class="w"> </span>1d42dba415e9<span class="w"> </span><span class="m">4</span><span class="w"> </span>seconds<span class="w"> </span>ago<span class="w"> </span><span class="m">32</span>.6MB
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="exploring-output-naming-with-dockertoolsexportimage">Exploring output naming with <code>dockerTools.exportImage</code></h1>
</div>
<p><code>exportImage</code> does not require a <code>name</code> attribute if <code>fromImage</code> is a derivation, which means that the following works:</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>exportImage <span class="p">{</span>
<span class="ss">fromImage</span> <span class="o">=</span> dockerTools<span class="o">.</span>buildLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<p>However, since <a href="#ssec-pkgs-dockerTools-buildLayeredImage"><code>dockerTools.buildLayeredImage</code></a>'s output ends with <code>.tar.gz</code>, the output of <code>exportImage</code> will also end with <code>.tar.gz</code>, even though the archive created with <code>exportImage</code> is uncompressed:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/by3f40xvc4l6bkis74l0fj4zsy0djgkn-hello.tar.gz
$<span class="w"> </span>file<span class="w"> </span>/nix/store/by3f40xvc4l6bkis74l0fj4zsy0djgkn-hello.tar.gz
/nix/store/by3f40xvc4l6bkis74l0fj4zsy0djgkn-hello.tar.gz:<span class="w"> </span>POSIX<span class="w"> </span>tar<span class="w"> </span>archive<span class="w"> </span><span class="o">(</span>GNU<span class="o">)</span>
</code></pre></div>
<p>If the archive was actually compressed, the output of file would've mentioned that fact.
Because of this, it may be important to set a proper <code>name</code> attribute when using <code>exportImage</code> with other functions from <code>dockerTools</code>.</p>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="using-dockertoolsexportimage-with-a-path-as-fromimage">Using <code>dockerTools.exportImage</code> with a path as <code>fromImage</code></h1>
</div>
<p>It is possible to use a path as the value of the <code>fromImage</code> attribute when calling <code>dockerTools.exportImage</code>.
However, when doing so, a <code>name</code> attribute <strong>MUST</strong> be specified, or you'll encounter an error when evaluating the Nix code.</p>
<p>For this example, we'll assume a Docker tarball image named <code>image.tar.gz</code> exists in the same directory where our package is defined:</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools <span class="p">}:</span>
dockerTools<span class="o">.</span>exportImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;filesystem.tar&quot;</span><span class="p">;</span>
<span class="ss">fromImage</span> <span class="o">=</span> <span class="l">./image.tar.gz</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
<p>Building this will give us the expected output:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/w13l8h3nlkg0zv56k7rj0ai0l2zlf7ss-filesystem.tar
</code></pre></div>
<p>If you don't specify a <code>name</code> attribute, you'll encounter an evaluation error and the package won't build.</p>
<h2 id="ssec-pkgs-dockerTools-helpers">Environment Helpers</h2>
<p>When building Docker images with Nix, you might also want to add certain files that are expected to be available globally by the software you're packaging.
Simple examples are the <code>env</code> utility in <code>/usr/bin/env</code>, or trusted root TLS/SSL certificates.
Such files will most likely not be included if you're building a Docker image from scratch with Nix, and they might also not be included if you're starting from a Docker image that doesn't include them.
The helpers in this section are packages that provide some of these commonly-needed global files.</p>
<p>Most of these helpers are packages, which means you have to add them to the list of contents to be included in the image (this changes depending on the function you're using to build the image).
<a href="#ex-dockerTools-helpers-buildImage"></a> and <a href="#ex-dockerTools-helpers-buildLayeredImage"></a> show how to include these packages on <code>dockerTools</code> functions that build an image.
For more details on how that works, see the documentation for the function you're using.</p>
<h3 id="sssec-pkgs-dockerTools-helpers-usrBinEnv">usrBinEnv</h3>
<p>This provides the <code>env</code> utility at <code>/usr/bin/env</code>.
This is currently implemented by linking to the <code>env</code> binary from the <code>coreutils</code> package, but is considered an implementation detail that could change in the future.</p>
<h3 id="sssec-pkgs-dockerTools-helpers-binSh">binSh</h3>
<p>This provides a <code>/bin/sh</code> link to the <code>bash</code> binary from the <code>bashInteractive</code> package.
Because of this, it supports cases such as running a command interactively in a container (for example by running <code>docker container run -it &lt;image_name&gt;</code>).</p>
<h3 id="sssec-pkgs-dockerTools-helpers-caCertificates">caCertificates</h3>
<p>This adds trusted root TLS/SSL certificates from the <code>cacert</code> package in multiple locations in an attempt to be compatible with binaries built for multiple Linux distributions.
The locations currently used are:</p>
<ul>
<li><code>/etc/ssl/certs/ca-bundle.crt</code></li>
<li><code>/etc/ssl/certs/ca-certificates.crt</code></li>
<li><code>/etc/pki/tls/certs/ca-bundle.crt</code></li>
</ul>
<p>[]{#ssec-pkgs-dockerTools-fakeNss}</p>
<h3 id="sssec-pkgs-dockerTools-helpers-fakeNss">fakeNss</h3>
<p>This is a re-export of the <code>fakeNss</code> package from Nixpkgs.
See <a href="#sec-fakeNss"></a>.</p>
<h3 id="ssec-pkgs-dockerTools-shadowSetup">shadowSetup</h3>
<p>This is a string containing a script that sets up files needed for <a href="https://github.com/shadow-maint/shadow"><code>shadow</code></a> to work (using the <code>shadow</code> package from Nixpkgs), and alters <code>PATH</code> to make all its utilities available in the same script.
It is intended to be used with other dockerTools functions in attributes that expect scripts.
After the script in <code>shadowSetup</code> runs, you'll then be able to add more commands that make use of the utilities in <code>shadow</code>, such as adding any extra users and/or groups.
See <a href="#ex-dockerTools-shadowSetup-buildImage"></a> and <a href="#ex-dockerTools-shadowSetup-buildLayeredImage"></a> to better understand how to use it.</p>
<p><code>shadowSetup</code> achieves a result similar to <a href="#sssec-pkgs-dockerTools-helpers-fakeNss"><code>fakeNss</code></a>, but only sets up a <code>root</code> user with different values for the home directory and the shell to use, in addition to setting up files for <a href="https://en.wikipedia.org/wiki/Linux_PAM">PAM</a> and a {manpage}<code>login.defs(5)</code> file.</p>
<p>{.caution}
Using both <code>fakeNss</code> and <code>shadowSetup</code> at the same time will either cause your build to break or produce unexpected results.
Use either <code>fakeNss</code> or <code>shadowSetup</code> depending on your use case, but avoid using both.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When used with <a href="#ssec-pkgs-dockerTools-buildLayeredImage"><code>buildLayeredImage</code></a> or <a href="#ssec-pkgs-dockerTools-streamLayeredImage"><code>streamLayeredImage</code></a>, you will have to set the <code>enableFakechroot</code> attribute to <code>true</code>, or else the script in <code>shadowSetup</code> won't run properly.
See <a href="#ex-dockerTools-shadowSetup-buildLayeredImage"></a>.</p>
</div>
<h3 id="ssec-pkgs-dockerTools-helpers-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Using `dockerTools`&#39;s environment helpers with `buildImage`
</code></pre></div>
<p>This example adds the <a href="#sssec-pkgs-dockerTools-helpers-binSh"><code>binSh</code></a> helper to a basic Docker image built with <a href="#ssec-pkgs-dockerTools-buildImage"><code>dockerTools.buildImage</code></a>.
This helper makes it possible to enter a shell inside the container.
This is the <code>buildImage</code> equivalent of <a href="#ex-dockerTools-helpers-buildLayeredImage"></a>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;env-helpers&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">copyToRoot</span> <span class="o">=</span> <span class="p">[</span>
hello
dockerTools<span class="o">.</span>binSh
<span class="p">];</span>
<span class="p">}</span>
</code></pre></div>
<p>After building the image and loading it in Docker, we can create a container based on it and enter a shell inside the container.
This is made possible by <code>binSh</code>.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/2p0i3i04cgjlk71hsn7ll4kxaxxiv4qg-docker-image-env-helpers.tar.gz
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load<span class="w"> </span>-i<span class="w"> </span>/nix/store/2p0i3i04cgjlk71hsn7ll4kxaxxiv4qg-docker-image-env-helpers.tar.gz
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>run<span class="w"> </span>--rm<span class="w"> </span>-it<span class="w"> </span>env-helpers:latest<span class="w"> </span>/bin/sh
sh-5.2#<span class="w"> </span><span class="nb">help</span>
GNU<span class="w"> </span>bash,<span class="w"> </span>version<span class="w"> </span><span class="m">5</span>.2.21<span class="o">(</span><span class="m">1</span><span class="o">)</span>-release<span class="w"> </span><span class="o">(</span>x86_64-pc-linux-gnu<span class="o">)</span>
<span class="o">(</span>rest<span class="w"> </span>of<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
</code></pre></div>
</div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="using-dockertoolss-environment-helpers-with-buildlayeredimage">Using <code>dockerTools</code>'s environment helpers with <code>buildLayeredImage</code></h1>
</div>
<p>This example adds the <a href="#sssec-pkgs-dockerTools-helpers-binSh"><code>binSh</code></a> helper to a basic Docker image built with <a href="#ssec-pkgs-dockerTools-buildLayeredImage"><code>dockerTools.buildLayeredImage</code></a>.
This helper makes it possible to enter a shell inside the container.
This is the <code>buildLayeredImage</code> equivalent of <a href="#ex-dockerTools-helpers-buildImage"></a>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;env-helpers&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span>
hello
dockerTools<span class="o">.</span>binSh
<span class="p">];</span>
<span class="ss">config</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<p>After building the image and loading it in Docker, we can create a container based on it and enter a shell inside the container.
This is made possible by <code>binSh</code>.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/rpf47f4z5b9qr4db4ach9yr4b85hjhxq-env-helpers.tar.gz
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load<span class="w"> </span>-i<span class="w"> </span>/nix/store/rpf47f4z5b9qr4db4ach9yr4b85hjhxq-env-helpers.tar.gz
<span class="o">(</span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>run<span class="w"> </span>--rm<span class="w"> </span>-it<span class="w"> </span>env-helpers:latest<span class="w"> </span>/bin/sh
sh-5.2#<span class="w"> </span><span class="nb">help</span>
GNU<span class="w"> </span>bash,<span class="w"> </span>version<span class="w"> </span><span class="m">5</span>.2.21<span class="o">(</span><span class="m">1</span><span class="o">)</span>-release<span class="w"> </span><span class="o">(</span>x86_64-pc-linux-gnu<span class="o">)</span>
<span class="o">(</span>rest<span class="w"> </span>of<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="using-dockertoolsshadowsetup-with-dockertoolsbuildimage">Using <code>dockerTools.shadowSetup</code> with <code>dockerTools.buildImage</code></h1>
</div>
<p>This is an example that shows how to use <code>shadowSetup</code> with <code>dockerTools.buildImage</code>.
Note that the extra script in <code>runAsRoot</code> uses <code>groupadd</code> and <code>useradd</code>, which are binaries provided by the <code>shadow</code> package.
These binaries are added to the <code>PATH</code> by the <code>shadowSetup</code> script, but only for the duration of <code>runAsRoot</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;shadow-basic&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">copyToRoot</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="ss">runAsRoot</span> <span class="o">=</span> <span class="s s-Multiline">&#39;&#39;</span>
<span class="s s-Multiline"> </span><span class="si">${</span>dockerTools<span class="o">.</span>shadowSetup<span class="si">}</span>
<span class="s s-Multiline"> groupadd -r hello</span>
<span class="s s-Multiline"> useradd -r -g hello hello</span>
<span class="s s-Multiline"> mkdir /data</span>
<span class="s s-Multiline"> chown hello:hello /data</span>
<span class="s s-Multiline"> &#39;&#39;</span><span class="p">;</span>
<span class="ss">config</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="ss">WorkingDir</span> <span class="o">=</span> <span class="s2">&quot;/data&quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="using-dockertoolsshadowsetup-with-dockertoolsbuildlayeredimage">Using <code>dockerTools.shadowSetup</code> with <code>dockerTools.buildLayeredImage</code></h1>
</div>
<p>It accomplishes the same thing as <a href="#ex-dockerTools-shadowSetup-buildImage"></a>, but using <code>buildLayeredImage</code> instead.</p>
<p>Note that the extra script in <code>fakeRootCommands</code> uses <code>groupadd</code> and <code>useradd</code>, which are binaries provided by the <code>shadow</code> package.
These binaries are added to the <code>PATH</code> by the <code>shadowSetup</code> script, but only for the duration of <code>fakeRootCommands</code>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildLayeredImage <span class="p">{</span>
<span class="ss">name</span> <span class="o">=</span> <span class="s2">&quot;shadow-basic&quot;</span><span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">contents</span> <span class="o">=</span> <span class="p">[</span> hello <span class="p">];</span>
<span class="ss">fakeRootCommands</span> <span class="o">=</span> <span class="s s-Multiline">&#39;&#39;</span>
<span class="s s-Multiline"> </span><span class="si">${</span>dockerTools<span class="o">.</span>shadowSetup<span class="si">}</span>
<span class="s s-Multiline"> groupadd -r hello</span>
<span class="s s-Multiline"> useradd -r -g hello hello</span>
<span class="s s-Multiline"> mkdir /data</span>
<span class="s s-Multiline"> chown hello:hello /data</span>
<span class="s s-Multiline"> &#39;&#39;</span><span class="p">;</span>
<span class="ss">enableFakechroot</span> <span class="o">=</span> <span class="no">true</span><span class="p">;</span>
<span class="ss">config</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">Cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;/bin/hello&quot;</span> <span class="p">];</span>
<span class="ss">WorkingDir</span> <span class="o">=</span> <span class="s2">&quot;/data&quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div>
<p>[]{#ssec-pkgs-dockerTools-buildNixShellImage-arguments}</p>
<h2 id="ssec-pkgs-dockerTools-buildNixShellImage">buildNixShellImage</h2>
<p><code>buildNixShellImage</code> uses <a href="#ssec-pkgs-dockerTools-streamNixShellImage"><code>streamNixShellImage</code></a> underneath to build a compressed Docker-compatible repository tarball of an image that sets up an environment similar to that of running <code>nix-shell</code> on a derivation.
Basically, <code>buildNixShellImage</code> runs the script created by <code>streamNixShellImage</code> to save the compressed image in the Nix store.</p>
<p><code>buildNixShellImage</code> supports the same options as <code>streamNixShellImage</code>, see <a href="#ssec-pkgs-dockerTools-streamNixShellImage"><code>streamNixShellImage</code></a> for details.</p>
<p>[]{#ssec-pkgs-dockerTools-buildNixShellImage-example}</p>
<h3 id="ssec-pkgs-dockerTools-buildNixShellImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Building a Docker image with `buildNixShellImage` with the build environment for the `hello` package
</code></pre></div>
<p>This example shows how to build the <code>hello</code> package inside a Docker container built with <code>buildNixShellImage</code>.
The Docker image generated will have a name like <code>hello-&lt;version&gt;-env</code> and tag <code>latest</code>.
This example is the <code>buildNixShellImage</code> equivalent of <a href="#ex-dockerTools-streamNixShellImage-hello"></a>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>buildNixShellImage <span class="p">{</span>
<span class="ss">drv</span> <span class="o">=</span> hello<span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a <code>.tar.gz</code> file that can be loaded into Docker:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/pkj1sgzaz31wl0pbvbg3yp5b3kxndqms-hello-2.12.1-env.tar.gz
$<span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load<span class="w"> </span>-i<span class="w"> </span>/nix/store/pkj1sgzaz31wl0pbvbg3yp5b3kxndqms-hello-2.12.1-env.tar.gz
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>hello-2.12.1-env:latest
</code></pre></div>
<p>After starting an interactive container, the derivation can be built by running <code>buildDerivation</code>, and the output can be executed as expected:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>run<span class="w"> </span>-it<span class="w"> </span>hello-2.12.1-env:latest
<span class="o">[</span>nix-shell:~<span class="o">]</span>$<span class="w"> </span>buildDerivation
Running<span class="w"> </span>phase:<span class="w"> </span>unpackPhase
unpacking<span class="w"> </span><span class="nb">source</span><span class="w"> </span>archive<span class="w"> </span>/nix/store/pa10z4ngm0g83kx9mssrqzz30s84vq7k-hello-2.12.1.tar.gz
<span class="nb">source</span><span class="w"> </span>root<span class="w"> </span>is<span class="w"> </span>hello-2.12.1
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Running<span class="w"> </span>phase:<span class="w"> </span>fixupPhase
shrinking<span class="w"> </span>RPATHs<span class="w"> </span>of<span class="w"> </span>ELF<span class="w"> </span>executables<span class="w"> </span>and<span class="w"> </span>libraries<span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1
shrinking<span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1/bin/hello
checking<span class="w"> </span><span class="k">for</span><span class="w"> </span>references<span class="w"> </span>to<span class="w"> </span>/build/<span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1...
gzipping<span class="w"> </span>man<span class="w"> </span>pages<span class="w"> </span>under<span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1/share/man/
patching<span class="w"> </span>script<span class="w"> </span>interpreter<span class="w"> </span>paths<span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1
stripping<span class="w"> </span><span class="o">(</span>with<span class="w"> </span><span class="nb">command</span><span class="w"> </span>strip<span class="w"> </span>and<span class="w"> </span>flags<span class="w"> </span>-S<span class="w"> </span>-p<span class="o">)</span><span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1/bin
<span class="o">[</span>nix-shell:~<span class="o">]</span>$<span class="w"> </span><span class="nv">$out</span>/bin/hello
Hello,<span class="w"> </span>world!
</code></pre></div>
</div>
<h2 id="ssec-pkgs-dockerTools-streamNixShellImage">streamNixShellImage</h2>
<p><code>streamNixShellImage</code> builds a <strong>script</strong> which, when run, will stream to stdout a Docker-compatible repository tarball of an image that sets up an environment similar to that of running <code>nix-shell</code> on a derivation.
This means that <code>streamNixShellImage</code> does not output an image into the Nix store, but only a script that builds the image, saving on IO and disk/cache space, particularly with large images.
See <a href="#ex-dockerTools-streamNixShellImage-hello"></a> to understand how to load in Docker the image generated by this script.</p>
<p>The environment set up by <code>streamNixShellImage</code> somewhat resembles the Nix sandbox typically used by <code>nix-build</code>, with a major difference being that access to the internet is allowed.
It also behaves like an interactive <code>nix-shell</code>, running things like <code>shellHook</code> (see <a href="#ex-dockerTools-streamNixShellImage-addingShellHook"></a>) and setting an interactive prompt.
If the derivation is buildable (i.e. <code>nix-build</code> can be used on it), running <code>buildDerivation</code> in the container will build the derivation, with all its outputs being available in the correct <code>/nix/store</code> paths, pointed to by the respective environment variables (e.g. <code>$out</code>).</p>
<p>{.caution}
The environment in the image doesn't match <code>nix-shell</code> or <code>nix-build</code> exactly, and this function is known not to work correctly for fixed-output derivations, content-addressed derivations, impure derivations and other special types of derivations.</p>
<h3 id="ssec-pkgs-dockerTools-streamNixShellImage-inputs">Inputs</h3>
<p><code>streamNixShellImage</code> expects one argument with the following attributes:</p>
<p><code>drv</code> (Attribute Set)</p>
<p>: The derivation for which the environment in the image will be set up.
Adding packages to the Docker image is possible by extending the list of <code>nativeBuildInputs</code> of this derivation.
See <a href="#ex-dockerTools-streamNixShellImage-extendingBuildInputs"></a> for how to do that.
Similarly, you can extend the image initialization script by extending <code>shellHook</code>.
<a href="#ex-dockerTools-streamNixShellImage-addingShellHook"></a> shows how to do that.</p>
<p><code>name</code> (String; <em>optional</em>)</p>
<p>: The name of the generated image.</p>
<p><em>Default value:</em> the value of <code>drv.name + "-env"</code>.</p>
<p><code>tag</code> (String or Null; <em>optional</em>)</p>
<p>: Tag of the generated image.
If <code>null</code>, the hash of the nix derivation that builds the Docker image will be used as the tag.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>uid</code> (Number; <em>optional</em>)</p>
<p>: The user ID to run the container as.
This can be seen as a <code>nixbld</code> build user.</p>
<p><em>Default value:</em> 1000.</p>
<p><code>gid</code> (Number; <em>optional</em>)</p>
<p>: The group ID to run the container as.
This can be seen as a <code>nixbld</code> build group.</p>
<p><em>Default value:</em> 1000.</p>
<p><code>homeDirectory</code> (String; <em>optional</em>)</p>
<p>: The home directory of the user the container is running as.</p>
<p><em>Default value:</em> <code>/build</code>.</p>
<p><code>shell</code> (String; <em>optional</em>)</p>
<p>: The path to the <code>bash</code> binary to use as the shell.
This shell is started when running the image.
This can be seen as an equivalent of the <code>NIX_BUILD_SHELL</code> <a href="https://nixos.org/manual/nix/stable/command-ref/nix-shell.html#environment-variables">environment variable</a> for {manpage}<code>nix-shell(1)</code>.</p>
<p><em>Default value:</em> the <code>bash</code> binary from the <code>bashInteractive</code> package.</p>
<p><code>command</code> (String or Null; <em>optional</em>)</p>
<p>: If specified, this command will be run in the environment of the derivation in an interactive shell.
A call to <code>exit</code> will be added after the command if it is specified, so the shell will exit after it's finished running.
This can be seen as an equivalent of the <code>--command</code> option in {manpage}<code>nix-shell(1)</code>.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<p><code>run</code> (String or Null; <em>optional</em>)</p>
<p>: Similar to the <code>command</code> attribute, but runs the command in a non-interactive shell instead.
A call to <code>exit</code> will be added after the command if it is specified, so the shell will exit after it's finished running.
This can be seen as an equivalent of the <code>--run</code> option in {manpage}<code>nix-shell(1)</code>.</p>
<p><em>Default value:</em> <code>null</code>.</p>
<h3 id="ssec-pkgs-dockerTools-streamNixShellImage-examples">Examples</h3>
<div class="admonition example">
<p class="admonition-title">Example</p>
<div class="highlight"><pre><span></span><code># Building a Docker image with `streamNixShellImage` with the build environment for the `hello` package
</code></pre></div>
<p>This example shows how to build the <code>hello</code> package inside a Docker container built with <code>streamNixShellImage</code>.
The Docker image generated will have a name like <code>hello-&lt;version&gt;-env</code> and tag <code>latest</code>.
This example is the <code>streamNixShellImage</code> equivalent of <a href="#ex-dockerTools-buildNixShellImage-hello"></a>.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>streamNixShellImage <span class="p">{</span>
<span class="ss">drv</span> <span class="o">=</span> hello<span class="p">;</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a script.
Running this script and piping it into <code>docker image load</code> gives you the same image that was built in <a href="#ex-dockerTools-buildNixShellImage-hello"></a>.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/8vhznpz2frqazxnd8pgdvf38jscdypax-stream-hello-2.12.1-env
$<span class="w"> </span>/nix/store/8vhznpz2frqazxnd8pgdvf38jscdypax-stream-hello-2.12.1-env<span class="w"> </span><span class="p">|</span><span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>hello-2.12.1-env:latest
</code></pre></div>
<p>After starting an interactive container, the derivation can be built by running <code>buildDerivation</code>, and the output can be executed as expected:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>run<span class="w"> </span>-it<span class="w"> </span>hello-2.12.1-env:latest
<span class="o">[</span>nix-shell:~<span class="o">]</span>$<span class="w"> </span>buildDerivation
Running<span class="w"> </span>phase:<span class="w"> </span>unpackPhase
unpacking<span class="w"> </span><span class="nb">source</span><span class="w"> </span>archive<span class="w"> </span>/nix/store/pa10z4ngm0g83kx9mssrqzz30s84vq7k-hello-2.12.1.tar.gz
<span class="nb">source</span><span class="w"> </span>root<span class="w"> </span>is<span class="w"> </span>hello-2.12.1
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Running<span class="w"> </span>phase:<span class="w"> </span>fixupPhase
shrinking<span class="w"> </span>RPATHs<span class="w"> </span>of<span class="w"> </span>ELF<span class="w"> </span>executables<span class="w"> </span>and<span class="w"> </span>libraries<span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1
shrinking<span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1/bin/hello
checking<span class="w"> </span><span class="k">for</span><span class="w"> </span>references<span class="w"> </span>to<span class="w"> </span>/build/<span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1...
gzipping<span class="w"> </span>man<span class="w"> </span>pages<span class="w"> </span>under<span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1/share/man/
patching<span class="w"> </span>script<span class="w"> </span>interpreter<span class="w"> </span>paths<span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1
stripping<span class="w"> </span><span class="o">(</span>with<span class="w"> </span><span class="nb">command</span><span class="w"> </span>strip<span class="w"> </span>and<span class="w"> </span>flags<span class="w"> </span>-S<span class="w"> </span>-p<span class="o">)</span><span class="w"> </span><span class="k">in</span><span class="w"> </span>/nix/store/f2vs29jibd7lwxyj35r9h87h6brgdysz-hello-2.12.1/bin
<span class="o">[</span>nix-shell:~<span class="o">]</span>$<span class="w"> </span><span class="nv">$out</span>/bin/hello
Hello,<span class="w"> </span>world!
</code></pre></div>
</div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="adding-extra-packages-to-a-docker-image-built-with-streamnixshellimage">Adding extra packages to a Docker image built with <code>streamNixShellImage</code></h1>
</div>
<p>This example shows how to add extra packages to an image built with <code>streamNixShellImage</code>.
In this case, we'll add the <code>cowsay</code> package.
The Docker image generated will have a name like <code>hello-&lt;version&gt;-env</code> and tag <code>latest</code>.
This example uses <a href="#ex-dockerTools-streamNixShellImage-hello"></a> as a starting point.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> cowsay<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>streamNixShellImage <span class="p">{</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">drv</span> <span class="o">=</span> hello<span class="o">.</span>overrideAttrs <span class="p">(</span>old<span class="p">:</span> <span class="p">{</span>
<span class="ss">nativeBuildInputs</span> <span class="o">=</span> old<span class="o">.</span>nativeBuildInputs <span class="ow">or</span> <span class="p">[]</span> <span class="o">++</span> <span class="p">[</span>
cowsay
<span class="p">];</span>
<span class="p">});</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a script which can be run and piped into <code>docker image load</code> to load the generated image.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/h5abh0vljgzg381lna922gqknx6yc0v7-stream-hello-2.12.1-env
$<span class="w"> </span>/nix/store/h5abh0vljgzg381lna922gqknx6yc0v7-stream-hello-2.12.1-env<span class="w"> </span><span class="p">|</span><span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>hello-2.12.1-env:latest
</code></pre></div>
<p>After starting an interactive container, we can verify the extra package is available by running <code>cowsay</code>:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>run<span class="w"> </span>-it<span class="w"> </span>hello-2.12.1-env:latest
<span class="o">[</span>nix-shell:~<span class="o">]</span>$<span class="w"> </span>cowsay<span class="w"> </span><span class="s2">&quot;Hello, world!&quot;</span>
<span class="w"> </span>_______________
&lt;<span class="w"> </span>Hello,<span class="w"> </span>world!<span class="w"> </span>&gt;
<span class="w"> </span>---------------
<span class="w"> </span><span class="se">\ </span><span class="w"> </span>^__^
<span class="w"> </span><span class="se">\ </span><span class="w"> </span><span class="o">(</span>oo<span class="o">)</span><span class="se">\_</span>______
<span class="w"> </span><span class="o">(</span>__<span class="o">)</span><span class="se">\ </span><span class="w"> </span><span class="o">)</span><span class="se">\/\</span>
<span class="w"> </span><span class="o">||</span>----w<span class="w"> </span><span class="p">|</span>
<span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">||</span>
</code></pre></div>
<div class="admonition example">
<p class="admonition-title">Example</p>
<h1 id="adding-a-shellhook-to-a-docker-image-built-with-streamnixshellimage">Adding a <code>shellHook</code> to a Docker image built with <code>streamNixShellImage</code></h1>
</div>
<p>This example shows how to add a <code>shellHook</code> command to an image built with <code>streamNixShellImage</code>.
In this case, we'll simply output the string <code>Hello, world!</code>.
The Docker image generated will have a name like <code>hello-&lt;version&gt;-env</code> and tag <code>latest</code>.
This example uses <a href="#ex-dockerTools-streamNixShellImage-hello"></a> as a starting point.</p>
<div class="highlight"><pre><span></span><code><span class="p">{</span> dockerTools<span class="p">,</span> hello <span class="p">}:</span>
dockerTools<span class="o">.</span>streamNixShellImage <span class="p">{</span>
<span class="ss">tag</span> <span class="o">=</span> <span class="s2">&quot;latest&quot;</span><span class="p">;</span>
<span class="ss">drv</span> <span class="o">=</span> hello<span class="o">.</span>overrideAttrs <span class="p">(</span>old<span class="p">:</span> <span class="p">{</span>
<span class="ss">shellHook</span> <span class="o">=</span> <span class="s s-Multiline">&#39;&#39;</span>
<span class="s s-Multiline"> </span><span class="si">${</span>old<span class="o">.</span>shellHook <span class="ow">or</span> <span class="s2">&quot;&quot;</span><span class="si">}</span>
<span class="s s-Multiline"> echo &quot;Hello, world!&quot;</span>
<span class="s s-Multiline"> &#39;&#39;</span><span class="p">;</span>
<span class="p">});</span>
<span class="p">}</span>
</code></pre></div>
<p>The result of building this package is a script which can be run and piped into <code>docker image load</code> to load the generated image.</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>nix-build
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
/nix/store/iz4dhdvgzazl5vrgyz719iwjzjy6xlx1-stream-hello-2.12.1-env
$<span class="w"> </span>/nix/store/iz4dhdvgzazl5vrgyz719iwjzjy6xlx1-stream-hello-2.12.1-env<span class="w"> </span><span class="p">|</span><span class="w"> </span>docker<span class="w"> </span>image<span class="w"> </span>load
<span class="o">(</span>some<span class="w"> </span>output<span class="w"> </span>removed<span class="w"> </span><span class="k">for</span><span class="w"> </span>clarity<span class="o">)</span>
Loaded<span class="w"> </span>image:<span class="w"> </span>hello-2.12.1-env:latest
</code></pre></div>
<p>After starting an interactive container, we can see the result of the <code>shellHook</code>:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>run<span class="w"> </span>-it<span class="w"> </span>hello-2.12.1-env:latest
Hello,<span class="w"> </span>world!
<span class="o">[</span>nix-shell:~<span class="o">]</span>$
</code></pre></div>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
<div class="md-copyright__highlight">
Licenced MIT
</div>
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
<div class="md-social">
<a href="https://git.auxolotl.org/auxolotl/docs" target="_blank" rel="noopener" title="Aux Docs Repo" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16.777 0a2.9 2.9 0 1 1-2.529 4.322H12.91a4.266 4.266 0 0 0-4.265 4.195v2.118a7.076 7.076 0 0 1 4.147-1.42l.118-.002h1.338a2.9 2.9 0 0 1 5.43 1.422 2.9 2.9 0 0 1-5.43 1.422H12.91a4.266 4.266 0 0 0-4.265 4.195v2.319A2.9 2.9 0 0 1 7.222 24 2.9 2.9 0 0 1 5.8 18.57V8.589a7.109 7.109 0 0 1 6.991-7.108l.118-.001h1.338A2.9 2.9 0 0 1 16.778 0ZM7.223 19.905a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.389Zm9.554-10.464a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.39Zm0-7.735a1.194 1.194 0 1 0 0 2.389 1.194 1.194 0 0 0 0-2.389Z"/></svg>
</a>
<a href="https://forum.aux.computer/" target="_blank" rel="noopener" title="Aux Forum" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.103 0C18.666 0 24 5.485 24 11.997c0 6.51-5.33 11.99-11.9 11.99L0 24V11.79C0 5.28 5.532 0 12.103 0zm.116 4.563a7.395 7.395 0 0 0-6.337 3.57 7.247 7.247 0 0 0-.148 7.22L4.4 19.61l4.794-1.074a7.424 7.424 0 0 0 8.136-1.39 7.256 7.256 0 0 0 1.737-7.997 7.375 7.375 0 0 0-6.84-4.585h-.008z"/></svg>
</a>
<a href="https://wiki.auxolotl.org/" target="_blank" rel="noopener" title="Aux Wiki" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.801 13.557c.148.098.288.202.417.313 1.854 1.6 3.127 4.656 2.582 7.311-1.091-.255-5.747-1.055-7.638-3.383-.91-1.12-1.366-2.081-1.569-2.885a5.65 5.65 0 0 0 .034-.219c.089.198.197.35.313.466.24.24.521.335.766.372.304.046.594-.006.806-.068l.001.001c.05-.015.433-.116.86-.342.325-.173 2.008-.931 3.428-1.566Zm-7.384 1.435C9.156 16.597 6.6 18.939.614 18.417c.219-1.492 1.31-3.019 2.51-4.11.379-.345.906-.692 1.506-1.009.286.168.598.332.939.486 2.689 1.221 3.903 1.001 4.89.573a1.3 1.3 0 0 0 .054-.025 6.156 6.156 0 0 0-.096.66Zm4.152-.462c.38-.341.877-.916 1.383-1.559-.389-.15-.866-.371-1.319-.591-.598-.29-1.305-.283-2.073-.315a4.685 4.685 0 0 1-.804-.103c.014-.123.027-.246.038-.369.062.104.673.057.871.057.354 0 1.621.034 3.074-.574 1.452-.608 2.55-1.706 3.022-3.225.474-1.52.22-3.091-.168-3.952-.169.709-1.453 2.381-1.926 2.871-.473.489-2.381 2.296-2.972 2.921-.7.74-.688.793-1.332 1.302-.202.19-.499.402-.563.53.027-.338.039-.675.027-.997a7.653 7.653 0 0 0-.032-.523c.322-.059.567-.522.567-.861 0-.224-.106-.247-.271-.229.075-.894.382-3.923 1.254-4.281.218.109.831.068.649-.295-.182-.364-.825-.074-1.081.266-.28.374-.956 2.046-.92 4.324-.113.014-.174.033-.322.033-.171 0-.321-.04-.433-.05.034-2.275-.714-3.772-.84-4.169-.12-.375-.491-.596-.781-.596-.146 0-.272.056-.333.179-.182.363.459.417.677.308.706.321 1.156 3.519 1.254 4.277-.125-.006-.199.035-.199.233 0 .311.17.756.452.843a.442.442 0 0 0-.007.03s-.287.99-.413 2.189a4.665 4.665 0 0 1-.718-.225c-.714-.286-1.355-.583-2.019-.566-.664.018-1.366.023-1.804-.036-.438-.058-.649-.15-.649-.15s-.234.365.257 1.075c.42.607 1.055 1.047 1.644 1.18.589.134 1.972.18 2.785-.377.16-.109.317-.228.459-.34a8.717 8.717 0 0 0-.013.626c-.289.753-.571 1.993-.268 3.338 0-.001.701-.842.787-2.958.006-.144.009-.271.01-.383.052-.248.103-.518.148-.799.072.135.151.277.234.413.511.842 1.791 1.37 2.383 1.49.091.019.187.032.285.038Zm-1.12.745c-.188.055-.445.1-.713.059-.21-.031-.45-.11-.655-.316-.169-.168-.312-.419-.401-.789a9.837 9.837 0 0 0 .039-.82l.049-.243c.563.855 1.865 1.398 2.476 1.522.036.008.072.014.109.02l-.013.009c-.579.415-.76.503-.891.558Zm6.333-2.818c-.257.114-4.111 1.822-5.246 2.363.98-.775 3.017-3.59 3.699-4.774 1.062.661 1.468 1.109 1.623 1.441.101.217.09.38.096.515a.57.57 0 0 1-.172.455Zm-9.213 1.62a1.606 1.606 0 0 1-.19.096c-.954.414-2.126.61-4.728-.571-2.023-.918-3.024-2.157-3.371-2.666.476.161 1.471.473 2.157.524.282.021.703.068 1.167.125.021.209.109.486.345.829l.001.001c.451.651 1.134 1.119 1.765 1.262.622.141 2.083.182 2.942-.407a3.12 3.12 0 0 0 .132-.093l.001.179a6.052 6.052 0 0 0-.221.721Zm5.512-1.271a17.49 17.49 0 0 1-1.326-.589c.437.042 1.054.083 1.692.108-.121.162-.244.323-.366.481Zm.932-1.26c-.12.17-.245.343-.373.517-.241.018-.478.03-.709.038a29.05 29.05 0 0 1-.741-.048c.608-.065 1.228-.252 1.823-.507Zm.22-.315c-.809.382-1.679.648-2.507.648-.472 0-.833.018-1.139.039v.001c-.324-.031-.665-.039-1.019-.054a3.555 3.555 0 0 1-.152-.009c.102-.002.192-.006.249-.006.363 0 1.662.034 3.151-.589 1.508-.632 2.645-1.773 3.136-3.351.37-1.186.31-2.402.086-3.312.458-.336.86-.651 1.147-.91.501-.451.743-.733.848-.869.199.206.714.864.685 2.138-.036 1.611-.606 3.187-1.501 4.154a9.099 9.099 0 0 1-1.321 1.132 11.978 11.978 0 0 0-.644-.422l-.089-.055-.051.091c-.184.332-.5.825-.879 1.374ZM4.763 5.817c-.157 1.144.113 2.323.652 3.099.539.776 2.088 2.29 3.614 2.505.991.14 2.055.134 2.055.134s-.593-.576-1.114-1.66c-.521-1.085-.948-2.104-1.734-2.786-.785-.681-1.601-1.416-2.045-1.945-.444-.53-.59-.86-.59-.86s-.656.175-.838 1.513Zm14.301 4.549a9.162 9.162 0 0 0 1.3-1.12c.326-.352.611-.782.845-1.265 1.315.145 2.399.371 2.791.434 0 0-.679 1.971-3.945 3.022l-.016-.035c-.121-.26-.385-.594-.975-1.036Zm-11.634.859a8.537 8.537 0 0 1-.598-.224c-1.657-.693-2.91-1.944-3.449-3.678-.498-1.601-.292-3.251.091-4.269.225.544.758 1.34 1.262 2.01a3.58 3.58 0 0 0-.172.726c-.163 1.197.123 2.428.687 3.24.416.599 1.417 1.62 2.555 2.193-.128.002-.253.003-.376.002Zm-1.758-.077c-.958-.341-1.901-.787-2.697-1.368C-.07 7.559 0 6.827 0 6.827s1.558-.005 3.088.179c.03.126.065.251.104.377.557 1.791 1.851 3.086 3.562 3.803l.047.019a4.254 4.254 0 0 1-.267-.026h-.001c-.401-.053-.595-.135-.595-.135l-.157-.069-.092.144-.017.029Zm6.807-1.59c.086.017.136.058.136.145 0 .197-.242.5-.597.597l-.01-.161a.887.887 0 0 0 .283-.243c.078-.099.142-.217.188-.338Zm-1.591.006c.033.1.076.197.129.282.061.097.134.18.217.24l-.021.083c-.276-.093-.424-.293-.424-.466 0-.078.035-.119.099-.139Zm-.025-.664c-.275-.816-.795-2.022-1.505-2.179-.296.072-.938.096-.691-.145.246-.24 1.085-.048 1.283.217.145.194.744.806 1.011 1.737l.032.227a.324.324 0 0 0-.13.143Zm1.454-.266c.251-.99.889-1.639 1.039-1.841.197-.265 1.036-.457 1.283-.217.247.241-.395.217-.691.145-.69.152-1.2 1.296-1.481 2.109a.364.364 0 0 0-.067-.059.37.37 0 0 0-.092-.043l.009-.094Zm4.802-2.708a9.875 9.875 0 0 1-.596.705c-.304.315-1.203 1.176-1.963 1.916.647-.955 1.303-1.806 2.184-2.376.123-.08.249-.161.375-.245Z"/></svg>
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../../../..", "features": ["content.tooltips", "search.highlight", "navigation.tabs", "navigation.indexes", "navigation.prune"], "search": "../../../../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../../../../assets/javascripts/bundle.fe8b6f2b.min.js"></script>
</body>
</html>