1 Use volume mounts to avoid including the Portage tree in your images:
3 $ docker run -d -name portage wking/portage
5 This exports a [VOLUME][] which you can [mount][volumes-from] from
8 $ docker run -volumes-from portage -i -t wking/gentoo /bin/bash
9 d1a49abc4b3c / # ls /usr/portage/
10 app-accessibility dev-python mail-mta sci-mathematics
13 Changes (e.g. distfiles downloads) are preserved between mounts by the
14 continuously-running `portage` container. Let's install something in
17 d1a49abc4b3c / # emerge -av netcat
19 These are the packages that would be fetched, in order:
21 Calculating dependencies... done!
22 [ebuild N ] dev-libs/libmix-2.05-r6 USE="-static-libs" 78 kB
23 [ebuild N ] net-analyzer/netcat-110-r9 USE="crypt ipv6 -static" 108 kB
25 Total: 2 packages (2 new), Size of downloads: 186 kB
27 Now kill that container and spin up another one:
29 $ docker run -volumes-from portage -i -t wking/gentoo /bin/bash
30 187adaf8babd / # emerge -pv netcat
32 These are the packages that would be merged, in order:
34 Calculating dependencies... done!
35 [ebuild N ] dev-libs/libmix-2.05-r6 USE="-static-libs" 0 kB
36 [ebuild N ] net-analyzer/netcat-110-r9 USE="crypt ipv6 -static" 0 kB
38 Total: 2 packages (2 new), Size of downloads: 0 kB
41 The local Portage cache, read news items, etc. stored outside of
42 `/usr/portage` (e.g. in `/var/cache/edb`, `/var/lib/gentoo/news`, …)
43 will still be local to your client containers, so you'll get
44 promptings for reading the news on both `d1a49abc4b3c` and
47 You can use container volumes even if their container is not running.
50 $ docker run -name portage wking/portage true
52 However, it may be useful to leave the container running so you don't
53 remove it up by accident.
55 [VOLUME]: http://docs.docker.io/en/latest/use/builder/#volume
56 [volumes-from]: http://docs.docker.io/en/latest/use/working_with_volumes/#mount-volumes-from-an-existing-container