-# Copyright (C) 2013 W. Trevor King <wking@tremily.us>
+# Copyright (C) 2013-2014 W. Trevor King <wking@tremily.us>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# -volumes-from doesn't map names, so we need to shift /portage to
# /usr/portage. Add a statically-linked BusyBox for RUN commands.
ADD busybox /bin/sh
-ENTRYPOINT ["/bin/sh"]
RUN mkdir /usr/
RUN mv /portage /usr/portage
VOLUME ["/usr/portage"]
-
-# We need a dummy process for this container
-CMD ["tail", "-f", "/portage/profiles/repo_name"]
+CMD sh
Use volume mounts to avoid including the Portage tree in your images:
- $ docker run -d --name portage wking/portage
+ $ docker run --name portage wking/portage
-This exports a [VOLUME][] which you can [mount][volumes-from] from
-another container:
+The container will exit immediately, but you can still
+[mount][volumes-from] it's exported [VOLUME][] from another container:
$ docker run --volumes-from portage -i -t wking/gentoo /bin/bash
d1a49abc4b3c / # ls /usr/portage/
…
Changes (e.g. distfiles downloads) are preserved between mounts by the
-continuously-running `portage` container. Let's install something in
-the first container:
+shared `portage` container. Let's install something in the first
+container:
d1a49abc4b3c / # emerge -av netcat
…
promptings for reading the news on both `d1a49abc4b3c` and
`187adaf8babd`.
-You can use container volumes even if their container is not running.
-For example:
+You can use container volumes even if their container is not running
+(as above), but it may be useful to leave the container running so you
+don't remove it up by accident. For example:
- $ docker run --name portage wking/portage true
-
-However, it may be useful to leave the container running so you don't
-remove it up by accident.
+ $ docker run -d --name portage wking/portage /bin/sh -c 'tail -f /usr/portage/profiles/repo_name'
[VOLUME]: http://docs.docker.io/en/latest/use/builder/#volume
[volumes-from]: http://docs.docker.io/en/latest/use/working_with_volumes/#mount-volumes-from-an-existing-container