/boot2docker

boot2docker.iso generator supporting phusion and solving ownership problems for files stored on shared with OSX directories.

Primary LanguageShell

Generator of boot2image.iso for OSX

This docker prepares an environment properly generating boot2docker.iso on OSX for OSX. The original boot2docker/boot2docker image is not working right for me.

The problem relates to inconsistency of the boot2docker.iso generate as the result of command

docker run --rm boot2docker/boot2docker > boot2docker.iso

For some reasons boot2docker.iso obtained vi ">" is not consisted with the one generated inside the docker process machine. Maybe the pipe traversing via three machines destroys the content.

Additional problem I've come across is lack of proper rights on shared directories from OSX.

Boot2docker automatically mounts /Users directory to the docker vm. However vboxfs which is exploited there is not properly preserving the ownerships of the created files. In the result there are some cases when processes creating files are not able to read their own files due to lack of permission.

To avoid that problem, the generated by this app boot2image.iso is mounting /Users directory with mask 0777, so all the files inside the docker machine stored on the shared folders will be seen as accessible for everyone under docker VMs. This is workaround well known problem with VBox sharing. It's not perfect but it works in typical developer scenarios.

This docker generates as well boot2docker.iso including tools for phusion/baseimage-docker. Now docker-ssh, docker-bash are loaded into boot2docker virtual machine and then can be easily proxied to OSX.

How to use this?

It works differently then the original docker (boot2docker/boot2docker). To run use the following command:

mkdir outiso
docker run --rm -t -i -v `pwd`/outiso/:/outiso luman75/boot2docker

The output of the boot2docker image will be stored into outiso directory. The file boot2docker.iso afterwords should be copied to your ~/.boot2docker

cp outiso/boot2docker.iso ~/.boot2docker

Now it's time to restart your boot2docker

boot2docker down
boot2docker up

To check if this is working properly, try to login to boot2docker VM using

boot2docker ssh

and now check permission of the files in /Users directory.

docker@boot2docker:~$ ls -la /Users
total 0
drwxrwxrwx    1 docker   staff          204 Oct 17 10:56 ./
drwxr-xr-x   18 root     root           420 Dec 22 19:38 ../
-rwxrwxrwx    1 docker   staff            0 Sep  9 22:16 .localized
drwxrwxrwx    1 docker   staff          408 Apr 17  2013 Guest/
drwxrwxrwx    1 docker   staff          442 Oct 17 10:56 Shared/
drwxrwxrwx    1 docker   staff         5508 Dec 22 09:33 XXXXXX/
docker@boot2docker:~$ 

If everything went ok, all files should have 0777 rights, as the above ones.

Proxing docker-bash

Because the VM machine now is equipped with docker-bash and docker-ssh tools for phusion/baseimage-docker you need to create a local (OSX) scripts tunneling requests to VM.

This is example docker-bash script:

#!/bin/sh                                                                                                               
                                                                                                                        
/usr/local/bin/boot2docker ssh -t "sudo docker-bash $@" 

having that script you can use docker-bash normally:

$ docker-bash
Usage: docker-bash <CONTAINER_ID> [COMMAND...]
Login to a Baseimage-based Docker container using nsenter. If COMMAND is not given, opens an interactive shell. Otherwise, runs COMMAND inside the container.