Skip to content

feat: temporarily move rw mounts during image build #187

Closed
@johnstcn

Description

@johnstcn
          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 #183 (comment)

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 #183 to include all volumes mounted in?

Activity

changed the title [-]feat: handle rw mounts[/-] [+]feat: temporarily move rw mounts during image build[/+] on May 14, 2024
assigned and unassigned on Aug 29, 2024
removed their assignment
on Oct 28, 2024
DanielleMaywood

DanielleMaywood commented on Nov 5, 2024

@DanielleMaywood
Contributor

I'm unable to reproduce the behaviour mentioned.

Attempting to reproduce this on our dogfood instance

$ docker --version
Docker version 27.3.0, build e85edf8
$ ls /home/coder/casts
new-cliui-select      new-prompt-multiple      new-prompt-rich-parameter  new-roles-edit       no-blink               original-create-workspace  original-prompt-multi-select    original-prompt-select  original-template-delete
new-create-workspace  new-prompt-multi-select  new-prompt-select          new-template-delete  original-cliui-select  original-prompt-multiple   original-prompt-rich-parameter  original-roles-edit

$ docker run --rm -it \
    -v /home/coder/casts/:/opt/casts:rw \
    -e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder-starter-devcontainer \
    -e ENVBUILDER_INIT_SCRIPT=bash \
    envbuilder:latest

devcontainer # ls /opt/casts/
new-cliui-select      new-prompt-multi-select  new-prompt-rich-parameter  new-roles-edit       no-blink               original-create-workspace     original-prompt-multiple        original-prompt-select  original-template-delete
new-create-workspace  new-prompt-multiple      new-prompt-select          new-template-delete  original-cliui-select  original-prompt-multi-select  original-prompt-rich-parameter  original-roles-edit

devcontainer # exit

$ ls /home/coder/casts
new-cliui-select      new-prompt-multiple      new-prompt-rich-parameter  new-roles-edit       no-blink               original-create-workspace  original-prompt-multi-select    original-prompt-select  original-template-delete
new-create-workspace  new-prompt-multi-select  new-prompt-select          new-template-delete  original-cliui-select  original-prompt-multiple   original-prompt-rich-parameter  original-roles-edit

Attempting to reproduce this on a Ubuntu 24.04 VM

$ docker --version
Docker version 27.3.1, build ce12230
$ ls /tmp/important
a  b  c

$ docker run --rm -it \
    -v /tmp/important:/opt/important:rw \
    -e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder-starter-devcontainer \
    -e ENVBUILDER_INIT_SCRIPT=bash \
    ghcr.io/coder/envbuilder:latest

devcontainer # ls /opt/important/
a  b  c

devcontainer # exit

$ ls /tmp/important
a  b  c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    feat: temporarily move rw mounts during image build · Issue #187 · coder/envbuilder