43a5bc90734483c9c3a1cfcb6bd39a169d9a375e
[dockerfile.git] / portage / README.md
1 Use volume mounts to avoid including the Portage tree in your images:
2
3     $ docker run -d -name portage wking/portage
4
5 This exports a [VOLUME][] which you can [mount][volumes-from] from
6 another container:
7
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
11     …
12
13 Changes (e.g. distfiles downloads) are preserved between mounts by the
14 continuously-running `portage` container.  Let's install something in
15 the first container:
16
17     d1a49abc4b3c / # emerge -av netcat
18     …
19     These are the packages that would be fetched, in order:
20
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
24
25     Total: 2 packages (2 new), Size of downloads: 186 kB
26
27 Now kill that container and spin up another one:
28
29     $ docker run -volumes-from portage -i -t wking/gentoo /bin/bash
30     187adaf8babd / # emerge -pv netcat
31     …
32     These are the packages that would be merged, in order:
33
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
37
38     Total: 2 packages (2 new), Size of downloads: 0 kB
39     …
40
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
45 `187adaf8babd`.
46
47 You can use container volumes even if their container is not running.
48 For example:
49
50     $ docker run -name portage wking/portage true
51
52 However, it may be useful to leave the container running so you don't
53 remove it up by accident.
54
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