1

I'm trying to do some customization on my boot2docker vm, and from what I can tell, I should be able to add a file: /var/lib/boot2docker/bootlocal.sh which should be executed when boot2docker starts, but it never seems to execute.

Here's my bootlocal.sh just to try to get it working:

!/bin/sh

echo 'testing bootlocal'
touch /var/lib/boot2docker/testfile

And I'm running boot2docker on OSX with this version info:

$ boot2docker version
Boot2Docker-cli version: v1.4.1
Git commit: 43241cb

I've also run chmod +x /var/lib/boot2docker/bootlocal.sh in case that script needs to be made executable.

I've tried both boot2docker restart and boot2docker down/up

Any idea what I may be missing?

sak
  • 2,612
  • 24
  • 55
  • 3
    Just a note, at least with docker 1.5, any echo or output in the bootlocal.sh is going to be located in: /var/log/bootlocal.log In case an error in the script is causing an issue. – phazei Feb 26 '15 at 04:11

2 Answers2

5

You need to set up a persistence partition with the volume name boot2docker-data.

  1. Add a new virtual disk to your VM.

  2. Create a new partition on the virtual disk using fdisk.

  3. Format the partition as ext4 - mkfs.ext4 -L boot2docker-data /dev/sdX1

  4. Reboot boot2docker and it will pick up the persistence partition.

  • Can you give any more detail on how I would go about doing this? I'm not that familiar with VM's so the documentation's not very clear to me, and I can't find any examples. – sak Dec 29 '14 at 06:15
  • I don't get this at all.. Can anybody confirm this step-by-step? How do you create virtual disk to VM? What operating system? How do you create new partition? How do you format partition? If you have two virtualdisks (one having boot2docker) how come rebooting the one with boot2docker will pick up persistence partition from this other virtual disk? Boom – jaycode Nov 19 '15 at 15:16
0

Adding to @Ben's answer and to clarify @jaycode's question on the comments

Its probably late, but here is my answer for windows 7.

To mount a folder from windows7 to the Docker-machine vm use the folowing command. Note that the docker machine shouldn't be running at this point.

You have to locate your installation of Oracle Virtual box that comes along with Docker-tools. Mine is at C:/Program Files/Oracle/VirtualBox/VBoxManage so replace it with your location. default is the name of the docker-machine to which the volume is mounted and E:/vm is the folder on the Windows7 machine that is to be shared with the docker-machine.

C:/Program Files/Oracle/VirtualBox/VBoxManage sharedfolder add default -name win_share -hostpath E:/vm 

Now you can ssh into the docker-machine with:

docker-machine ssh default

Then perform the mount:

Make a folder inside the VM:

sudo mkdir /vm

Mount the Windows folder to it:

sudo mount -t vboxsf win_share /vm

After that, you can access E:/vm inside your Docker-machine:

You can refer https://stackoverflow.com/a/30865500/4396129