2

I have docker setup on my Windows system. The source code of the application is available at C:\Application\source location. I want this information to be available within the docker container so that it is easy to make code changes during development without rebuilding the image.

This is what I tried

docker run -d -P -i -t -p 8083:8080 --name html-app -v /c/Application/source:/usr/src html-app-img:vnode

The image html-app is based on Node JS

Now when I do a docker exec -it html-app /bin/bash , it doesn't show the contents of C:\Application\source there. I thought that should be available right? In the Oracle Virtual box, I've shared the folder C:\Application

Is there anything else that I need to do to get this working?

Apps
  • 3,284
  • 8
  • 48
  • 75

1 Answers1

1

In the Oracle Virtual box, I've shared the folder C:\Application

That is not enough. You need to modify your boot2docker image in order for the TinyCore Linux session to mount the shared path (only C:\Users\<yourlogin> is mounted by default as /c/Users/<yourLogin>)

See "Docker Compose Mount Window Folder"

Edit/create (as root) /mnt/sda1/var/lib/boot2docker/bootlocal.sh, (sda1 may be different for you)

Add:

mkdir -p <local_dir>
mount -t vboxsf -o defaults,uid=`id -u docker`,gid=`id -g docker` <mount_name> <local_dir>

(the mount might need umask option as well)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks Von. Let's say I have 'node_modules' folder inside /usr/src. So when I mount the source code (which doesn't have 'node_modules' folder) why doesn't both the layers show up? I see only the contents inside C:\Application\src now – Apps Feb 24 '16 at 17:13
  • If you see the content of Application/src, isn't it what you asked originally? And where is /usr/... ? Is it in your boot2docker session? – VonC Feb 24 '16 at 17:16
  • /usr/ is a work directory is created inside the container. Is there a way by which we can have contents from /usr and c:\Appllication\source? – Apps Feb 24 '16 at 17:31
  • Yes with -v, to mount the host folder to the container – VonC Feb 24 '16 at 17:37
  • I did that, but I see only the contents in C:/Application/src and not the one in /usr/src – Apps Feb 24 '16 at 17:47
  • @Apps when you say " I see only the contents in `C:/Application/src`", this is in the boot2docker Linux session, right? "and not the one in `/usr/src`": this time, it is in the container launched by `docker run`, correct? – VonC Feb 24 '16 at 20:17
  • @Apps Are you using a git bash or Cygwin on your Windows host? Or do you make your ssh session from a regular CMD shell? The former won't work well (https://github.com/boot2docker/boot2docker/issues/846#issuecomment-97526663) – VonC Feb 24 '16 at 20:28
  • I'm using the docker terminal that gets installed as part of docker-toolbox – Apps Feb 24 '16 at 21:10
  • @Apps try a simple CMD in which you type `docker-machine ssh ` – VonC Feb 24 '16 at 21:27
  • I'm able to ssh to docker-machine. But I still have the same issue – Apps Feb 24 '16 at 21:37