coder / envbuilder

Build development environments from a Dockerfile on Docker, Kubernetes, and OpenShift. Enable developers to modify their development environment quickly.
Apache License 2.0
123 stars 24 forks source link

feat: temporarily move rw mounts during image build #187

Open johnstcn opened 3 months ago

johnstcn commented 3 months ago
          This is an interesting question, should we or should we not limit this to read-only mounted filesystems? If we think about how a docker container is run with `-v /path:/path`, the contents of the docker container can never populate the mounted `/path`.

_Originally posted by @mafredri in https://github.com/coder/envbuilder/pull/183#discussion_r1598536663_

Currently, mounting in read-write volumes results in their contents not being available inside the container:

$ echo 'important stuff' >> /opt/important-stuff/tps-reports.txt
$ ls -l /opt/important-stuff/tps-reports.txt 
-rw-r--r-- 1 cian 16 May 13 21:12 /opt/important-stuff/tps-reports.txt
$ docker run -it --rm \
    -v /opt/important-stuff:/opt/important-stuff \
    -e GIT_URL=https://github.com/coder/envbuilder-starter-devcontainer \
    -e INIT_SCRIPT=bash \
    envbuilder:latest
[...]
devcontainer # ls -l /opt/important-stuff/
total 0
devcontainer # exit
$ cat /opt/important-stuff/tps-reports.txt
important stuff

Can we extend https://github.com/coder/envbuilder/pull/183 to include all volumes mounted in?