How to deploy Dockerfile and application files to boot2docker
Solution 1
Not sure if it helps under windows. But for Mac see:
boot2docker together with VirtualBox Guest Additions
How to mount /Users into boot2docker
tl;dr Build your own custom boot2docker.iso with VirtualBox Guest Additions (see link) or download http://static.dockerfiles.io/boot2docker-v1.0.1-virtualbox-guest-additions-v4.3.12.iso and save it to ~/.boot2docker/boot2docker.iso.
Solution 2
Following your current progress, and presuming your samba container is running, you can find the path to the /data folder on your Boot2docker VM by running:
$ docker inspect <samba_container_id>
This will list the containers configuration details. Near the very bottom you should see:
"Volumes": {
"/data": "/mnt/sda1/var/lib/docker/vfs/dir/<long_id_here>
That's your boot2docker vm /data path. Simply cd into that folder
$ cd /mnt/sda1/var/lib/docker/vfs/dir/<long_id_here>
From Windows Explorer, Navigate to:
\\192.168.59.103\data
Now you can paste/copy/create some files into that data folder and you should see them populate on your Boot2docker VM at path: /mnt/sda1/var/lib/docker/vfs/dir/<long_folder_id_here>
Solution 3
IMHO the best way would be to use scp. As you can ssh, you can use winscp to send the Dockerfile to the VM.
Solution 4
ssh the file into your VM
dockerfile=$(cat LocalDockerfile)
boot2docker ssh "echo '$dockerfile' > Dockerfile"
wrote it up here http://micahasmith.github.io/2014/11/07/copying-files-into-boot2docker/
Solution 5
On Boot2Docker change your directory "cd /c" you will be able to see Users folders on Windows. Put the content you wanna share in your prefered Users Folders.
Comments
-
Christian Rondeau about 2 years
I'm just starting to learn Docker, and I'm trying to get a simple setup with boot2docker on Windows. I could not find in any tutorial or samples online how to make my project files accessible to the boot2docker VM.
I downloaded boot2docker, and succeeded in installing it and getting it up and running. I can also ssh into it and run the hello world docker example, so I know I have a working Docker installation in the VM.
Now, the question: How do I get my
Dockerfile
and my application files on the boot2docker VM so that I can build a Docker container?In other words, I'm trying to do this from the boot2docker VM:
$ cd /some-directory-from-my-host-os $ docker build .
I tried following the instructions on https://github.com/boot2docker/boot2docker#folder-sharing and setup a SAMBA share, and I can successfully connect from Windows to the share at
\\192.168.59.103\data
but that doesn't tell me how to access that same directory from within the boot2docker VM.I feel like the answer might be obvious, but I'm sure I'm not the only one who will hit that wall. Thanks for your help!
Update - Now Built-In in boot2docker 1.3!
Since boot2docker 1.3, the ability to mount a shared folder has been added, so the VM can share your dev folder directly. More information here: https://github.com/boot2docker/boot2docker#virtualbox-guest-additions
-
Christian Rondeau about 10 yearsThis may be a good solution, but this also means as I create a Dockerfile along with my application files on my machine, I have to copy them on the VM, and then switch to the boot2docker bash and run docker. I'd like a solution where I can map to my drive directly. I'm looking into mounting a share on my Windows machine into boot2docker, if I cannot find an easy solution I'll vote your answer up. Thanks!
-
creack about 10 yearsThere must be a way to use virtualbox shared folder, samba, nfs or other to mount your windows folder in the vm, but can't help your there. scp is the dumb solution that just works :)
-
Christian Rondeau about 10 yearsEven though I'd still prefer to map a directory on my Windows host directly (like we can do with VirtualBox when using Vagrant), this is the path I was searching for!
-
Admin about 10 yearsTo map a directory to the already established network share, you can create a SymLink (Directory Symbolic Link) using "mklink" on Vista/7/8, or "Junction" on XP. ie: Open CMD.exe as Admin, Then run:
mklink /D C:\path\to\data \\192.168.59.103\data
-
Christian Rondeau about 10 yearsWhat I meant is to have the files on my host, so that if I power off the boot2docker VM I can still fetch updates from our internal GIT scripts repository and work locally. My best option right now is to sync files using robocopy /MIR so that my original files are not living only on the Docker SAMBA container.
-
Admin about 10 yearsOffline Files allows you to access network files while working offline (Boot2docker VM powered off). To set up Offline Files open a network folder:
Network > 192.168.59.103\data
Right click on a file or folder, and select "Always Available Offline". To manage all your sync settings, Nav to:Control Panel > All Control Panel Items > Sync Center
-
Christian Rondeau about 10 yearsFor those following this thread, there is a (debated) pull request to allow VirtualBox extensions: github.com/boot2docker/boot2docker/pull/284
-
Vincent De Smet almost 10 yearsso, b2d 1.3 will most likely have a share feature - until then it is recommended to use the samba share method to ensure maximum portability - it's really not that hard: github.com/boot2docker/boot2docker/issues/474
-
Piotr Trzpil almost 10 yearsOne thing to note: it is not clear from the instructions on the website, that the host directory will be mounted as /Users on the VM, regardless of the name given and host directory name
-
Larry Cai over 9 yearsnow can be updated to indicate from 1.3.0, your feature is added.