Docker mounting volume for editing source code

2019-02-15 22:43发布

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?

标签: docker
1条回答
Fickle 薄情
2楼-- · 2019-02-15 23:23

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)

查看更多
登录 后发表回答