From: W. Trevor King Date: Fri, 20 Jun 2014 04:36:55 +0000 (-0700) Subject: portage: Shift the emphasis from a running to a non-running container X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bdc781050683a91554b87dd9216fca61ec429cff;p=dockerfile.git portage: Shift the emphasis from a running to a non-running container Not messing with ENTRYPOINT makes it easier to run an interactive container with: $ docker run --rm -i -t wking/portage if you want to poke around. --- diff --git a/portage/Dockerfile.template b/portage/Dockerfile.template index 7c321f9..ca846f3 100644 --- a/portage/Dockerfile.template +++ b/portage/Dockerfile.template @@ -1,4 +1,4 @@ -# Copyright (C) 2013 W. Trevor King +# Copyright (C) 2013-2014 W. Trevor King # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -28,10 +28,7 @@ MAINTAINER ${MAINTAINER} # -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 diff --git a/portage/README.md b/portage/README.md index 2fbac74..0fd20a7 100644 --- a/portage/README.md +++ b/portage/README.md @@ -1,9 +1,9 @@ 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/ @@ -11,8 +11,8 @@ another container: … 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 … @@ -44,13 +44,11 @@ will still be local to your client containers, so you'll get 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