docker-rpi-emu icon indicating copy to clipboard operation
docker-rpi-emu copied to clipboard

Mount folder in container to host?

Open psiie opened this issue 7 years ago • 3 comments

Is it possible to mount a folder inside the container to the host? I have tried countless times mounting folders using the -v flag in docker, but I have a strange suspicion that due to the emulation it is not possible.

Thoughts? Ideas?

psiie avatar Jul 15 '17 07:07 psiie

So this whole docker emulation thing is kindof turtles all the way down, if you have a linux (or maybe osx) machine & are willing to play with the scripts you should be able to get it running natively which is way more sensible IMO.

If you want a mounted folder to be available within the image you're probably going to need to -v it into the docker machine, then, after mounting the disk image but before the chroot symlink from a directory in the mounted image back to the share in the docker machine.

I /think/ it should be possible / totally work, but, will be interested to hear back how it goes ^_^

ryankurte avatar Jul 15 '17 07:07 ryankurte

Symlinking didn't work for me. Was able to -v and then mount --bind before running chroot

docker-compose.yml

#...
emulated:
  build: 
    context: .
    dockerfile: pi.Dockerfile
  privileged: true
  volumes:
    - ./:/usr/rpi/images
    - ./:/opt/app
  command: ./run-rpi-emu.sh images/voltlet.1.1.8.mini.img /bin/bash

Important bits of my https://github.com/ryankurte/docker-rpi-emu/blob/625d8813ea/scripts/run.sh replacement.

#...
# Mount ISO
./mount.sh $1 $MOUNT_DIR

mkdir "$MOUNT_DIR/opt/app"
mount --bind /opt/app /media/rpi/opt/app
#...

maxmcd avatar Sep 24 '18 13:09 maxmcd

@maxmcd I'm trying to get this to work using docker compose but to no avail. Any chance you could share your setup in a gist or something? What commands do you run in run-rpi-emu.sh? I was also wondering why the volume mapping is ./:/usr/rpi/mages… wouldn't that be ./images:/usr/rpi/images? Similarly for the /opt/app mount?

bummzack avatar May 06 '21 08:05 bummzack