This blog is part of my Docker series. In my previous blog, I covered installation and usage of Docker on Ubuntu Linux. I had installed Ubuntu Linux as a VM inside Virtualbox running in Windows 7. For folks who are interested in trying Docker using a simpler approach on Windows or Mac, boot2docker is an option.
boot2docker:
Docker is supported currently only on Linux kernel. boot2docker is a tiny distribution of Linux on top of which Docker is installed. Installing boot2docker on Windows would allow us to run Docker on Windows machine. Actually boot2docker runs as a VM on top of Virtualbox. During installation, an option is given to install Virtualbox along with boot2docker. If you have Virtualbox already installed, you can select installation of only boot2docker, otherwise you can install both together. boot2docker for Windows can be installed from here. It does not make much sense to run boot2docker in Linux since Docker is supported natively in Linux and there will be performance impact of running boot2docker in a VM under Linux. Infact, I did not seen an option to install boot2docker under Linux.
Once boot2docker installation is done, following options would be seen when “boot2docker” is typed from Windows console.
> boot2docker Usage: C:\Program Files\Boot2Docker for Windows\boot2docker.exe [] {help|init|up|ssh|save|down|poweroff|reset|r estart|config|status|info|ip|shellinit|delete|download|upgrade|version} []
boot2docker can be started using 2 approaches:
- Click on “boot2docker start” icon in Windows desktop.
- Type “boot2docker init” followed by “boot2docker start” from Windows console.
After boot2docker is started, following would be the status outputs:
> boot2docker status running > boot2docker info { "Name": "boot2docker-vm", "UUID": "d19c5bcc-229c-4735-a592-1da889b33d3f", "Iso": "c:\\Users\\srmakam\\.boot2docker\\boot2docker.iso", "State": "running", "CPUs": 8, "Memory": 2048, "VRAM": 8, "CfgFile": "C:\\\\Users\\\\srmakam\\\\VirtualBox VMs\\\\boot2docker-vm\\\\boot2docker-vm.vbox", "BaseFolder": "C:\\Users\\srmakam\\VirtualBox VMs\\boot2docker-vm", "OSType": "", "Flag": 0, "BootOrder": null, "DockerPort": 0, "SSHPort": 2022, "SerialFile": "\\\\.\\pipe\\boot2docker-vm"
To ssh to the boot2docker linux machine, do the following:
> boot2docker ssh ## . ## ## ## == ## ## ## ## === /""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\______/ _ _ ____ _ _ | |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __ | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ | |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| Boot2Docker version 1.4.1, build master : 86f7ec8 - Tue Dec 16 23:11:29 UTC 2014 Docker version 1.4.1, build 5bc2ff8 docker@boot2docker:~$
From the linux console, regular docker commands can be executed.
docker@boot2docker:~$ docker run hello-world Unable to find image 'hello-world:latest' locally hello-world:latest: The image you are pulling has been verified 31cbccb51277: Pull complete e45a5af57b00: Pull complete 511136ea3c5a: Already exists Status: Downloaded newer image for hello-world:latest Hello from Docker. This message shows that your installation appears to be working correctly.
I installed few containers and following command shows images downloaded.
docker@boot2docker:~$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest b39b81afc8ca 4 days ago 188.3 MB hello-world latest e45a5af57b00 2 weeks ago 910 B busybox latest 4986bf8c1536 2 weeks ago 2.433 MB
Note:
When I was trying uninstall and reinstall of boot2docker, I faced this issue:
PS C:\Program Files\Boot2Docker for Windows> .\boot2docker.exe init -v . . 2015/01/20 23:13:08 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe list hostonlyifs error in run: Failed to initialize machine "boot2docker-vm": strconv.ParseUint: parsing "128": value out of range
I saw that few other folks faced similar issue. The way I worked around this issue is by removing the host-only interface created by boot2docker in Virtualbox and then reinstalling boot2docker.
The tiny linux installed does not have many capabilities like guest additions that allows for file sharing between native host and containers. I found the approach specified here to be useful, this allows building a custom boot2docker image with the capabilities we need.
1 thought on “Docker hands-on with boot2docker”