-
-
Save johannespetzold/05b2fc00793a6ec0b0d6 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex | |
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 | |
docker build -t my-boot2docker-img . | |
docker run --rm my-boot2docker-img > boot2docker.iso |
FROM boot2docker/boot2docker | |
RUN apt-get -y install p7zip-full | |
ENV VBOX_VERSION 4.3.12 | |
# Build VBox guest additions | |
RUN mkdir -p /vboxguest && \ | |
cd /vboxguest && \ | |
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/${VBOX_VERSION}/VBoxGuestAdditions_${VBOX_VERSION}.iso && \ | |
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \ | |
sh VBoxLinuxAdditions.run --noexec --target . && \ | |
mkdir x86 && cd x86 && tar xvjf ../VBoxGuestAdditions-x86.tar.bz2 && cd .. && \ | |
mkdir amd64 && cd amd64 && tar xvjf ../VBoxGuestAdditions-amd64.tar.bz2 && cd .. && \ | |
cd amd64/src/vboxguest-${VBOX_VERSION} && KERN_DIR=/linux-kernel/ make && cd ../../.. && \ | |
cp amd64/src/vboxguest-${VBOX_VERSION}/*.ko $ROOTFS/lib/modules/$KERNEL_VERSION-tinycore64 && \ | |
mkdir -p $ROOTFS/sbin && cp x86/lib/VBoxGuestAdditions/mount.vboxsf $ROOTFS/sbin/ | |
RUN depmod -a -b $ROOTFS $KERNEL_VERSION-tinycore64 | |
RUN /make_iso.sh | |
CMD ["cat", "boot2docker.iso"] |
Hi Johannes
I have followed your howto, and was able to patch boot2docker. However, when I run your last command:
$touch $HOME/workspace/hello
$ls -l $HOME/workspace
total 0
-rw-r--r-- 1 lmuniz staff 0 Aug 23 14:02 hello
$docker run -v $HOME/workspace:/workspace ubuntu ls /workspace
I get nothing.
The volume does seem to come from somewhere persistent, though, because:
$docker run -t -i -v $HOME/workspace:/workspace ubuntu /bin/bash
root@75c92d2786d5:/#touch /workspace/world
root@75c92d2786d5:/#ls /workspace/
world
root@75c92d2786d5:/#exit
$ls -l $HOME/workspace
total 0
-rw-r--r-- 1 lmuniz staff 0 Aug 23 14:02 hello
$docker run -t -i -v $HOME/workspace:/workspace ubuntu /bin/bash
root@75c92d2786d5:/#ls /workspace/
world
So the created file world
does exist somewhere on a persistent folder.
When I inspect the container:
$ docker inspect 3ec323fa3d58 | grep -C 10 workspace
"Tty": true,
"User": "",
"Volumes": null,
"WorkingDir": ""
},
"Created": "2014-08-23T12:18:46.97519695Z",
"Driver": "aufs",
"ExecDriver": "native-0.2",
"HostConfig": {
"Binds": [
"/Users/lmuniz/workspace:/workspace"
],
"CapAdd": null,
"CapDrop": null,
"ContainerIDFile": "",
"Devices": null,
"Dns": null,
"DnsSearch": null,
"Links": null,
"LxcConf": [],
"NetworkMode": "bridge",
--
--
"State": {
"ExitCode": 0,
"FinishedAt": "0001-01-01T00:00:00Z",
"Paused": false,
"Pid": 868,
"Restarting": false,
"Running": true,
"StartedAt": "2014-08-23T12:18:47.25630493Z"
},
"Volumes": {
"/workspace": "/Users/lmuniz/workspace"
},
"VolumesRW": {
"/workspace": true
}
}
Finally, a sanity check to make sure that $HOME/workspace
resolves to /Users/lmuniz/workspace
:
$echo "$HOME/workspace"
/Users/lmuniz/workspace
Do you have an idea of what may be going on?
Hi Luis, sorry for late response, just noticed your comment. I think the problem was that add-share.sh included "/Users/pivotal/workspace" instead of $HOME/workspace, which was the same on my machine but not on yours. I fixed it, so hopefully this will work for you now.
Hi @johannespetzold,
I tried to use your scripts but every single time I get this (the container builds correctly):
modprobe: module vboxsf not found in modules.dep
2014/09/10 14:15:17 exit status 1
Have you come across this?
Hello @ johannespetzold
I tried to use your scripts but every single time I get this (the container builds correctly):
modprobe: module vboxsf not found in modules.dep
2014/09/10 14:15:17 exit status 1
Have you come across this?
How to use:
git clone https://gist.github.com/johannespetzold/05b2fc00793a6ec0b0d6
cd 05b2fc00793a6ec0b0d6
bash build-image.sh
mv boot2docker.iso ~/.boot2docker
bash add-share.sh
To verify:
docker run -v $HOME/workspace:/workspace ubuntu ls /workspace
should list the contents of $HOME/workspace on the host.Source: boot2docker/boot2docker#284