Skip to content

host-mounted volumes in Dockerfile's VOLUME #3156

@wking

Description

@wking

In #1124, there was an explicit decision to not allow host-mounted volumes via the VOLUME command. However, I think I have a good use case for supporting host-mounts via VOLUME. Gentoo stores it's package repository under /usr/portage. I'm trying to set up a workflow like:

$ cat Dockerfile
FROM gentoo
VOLUME ["/usr/portage:/usr/portage:ro", "/usr/portage/distfiles:/usr/portage/distfiles:rw"]
RUN emerge sys-process/vixie-cron app-admin/syslog-ng app-admin/logrotate
RUN rc-update add syslog-ng default
RUN rc-update add vixie-cron default
$ docker import - gentoo < stage3-amd64-20131205.tar.bz2
$ docker build -t gentoo-syslog .

However, VOLUME doesn't support that, and docker build … doesn't support the -v tag. The end goal is to get a production image that doesn't include /usr/portage, since the package repository just bloats the production container. I can think of a few workarounds including NFS-mounting /usr/portage during the build or using:

$ docker run -v /usr/portage:/usr/portage:ro -v /usr/portage/distfiles:/usr/portage/distfiles:rw gentoo emerge …
$ docker commit …

for each of the build steps, but native Dockerfile support would be nice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/builderBuildarea/volumesVolumeskind/enhancementEnhancements are not bugs or new features but can improve usability or performance.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions