{"id":1467,"date":"2015-01-16T13:42:49","date_gmt":"2015-01-16T17:42:49","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=1467"},"modified":"2015-01-16T13:42:49","modified_gmt":"2015-01-16T17:42:49","slug":"modify-boot2docker-iso","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2015\/modify-boot2docker-iso\/","title":{"rendered":"Adding a package to boot2docker"},"content":{"rendered":"<p>Docker\u00a0is seeing rapid adoption among the software development world. So far it seems to me a very nice way to make software installation much less painful, but there\u00a0is still plenty of room for improvement.<\/p>\n<p>If you&#8217;re running Linux then you can stop reading now.\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Docker_%28software%29\" target=\"_blank\">Docker<\/a>\u00a0is an abstraction layer over <a href=\"http:\/\/en.wikipedia.org\/wiki\/LXC\" target=\"_blank\">Linux Containers<\/a> (LXC), they&#8217;ve also created a <a href=\"http:\/\/dockerhub.com\/\" target=\"_blank\">repository <\/a>where pre-defined containers can be found &#8211; you can even add your own.\u00a0LXC is cool stuff, but it does mean\u00a0Docker\u00a0runs Linux.<\/p>\n<p>Windows and OSX users need to use <a href=\"http:\/\/boot2docker.io\/\" target=\"_blank\">boot2docker<\/a>, a\u00a0Tiny Core Linux virtual machine that\u00a0has just enough stuff to run docker.\u00a0This is\u00a0a fine solution but often when people ask about missing tools inside of boot2docker, the answer is to install a container that has the tools you want and run inside of that container. Things quickly start to feel like\u00a0<a href=\"http:\/\/www.imdb.com\/title\/tt1375666\/\" target=\"_blank\">Inception<\/a>.<\/p>\n<p>Boot2docker is based on <a href=\"http:\/\/distro.ibiblio.org\/tinycorelinux\/\" target=\"_blank\">Tiny Core Linux<\/a>,\u00a0so you can use the tce-load utility to install additional components if needed. So say we wanted to run Perl:<\/p>\n<p><code>$ tce-load -wi perl5<\/code><\/p>\n<p>You can sniff around\u00a0the <a href=\"http:\/\/distro.ibiblio.org\/tinycorelinux\/tcz_2x.html\" target=\"_blank\">repository<\/a> to figure out what packages are available.<\/p>\n<p>There is <a href=\"https:\/\/github.com\/boot2docker\/boot2docker\/blob\/master\/doc\/FAQ.md\" target=\"_blank\">documentation on adding a persistent partition<\/a> to your boot2docker setup. This is useful if you want to run the\u00a0tce-load every time you run without having to type it in each time. Getting this setup is a little bit fiddly,\u00a0and if we&#8217;re clever we can do something a bit cooler.<\/p>\n<p>Let&#8217;s build a custom\u00a0boot2docker.iso file! The build process is <a href=\"https:\/\/github.com\/boot2docker\/boot2docker\/blob\/master\/doc\/BUILD.md\" target=\"_blank\">nicely documented<\/a>. We can use a <a href=\"https:\/\/docs.docker.com\/reference\/builder\/\" target=\"_blank\">Dockerfile <\/a>to create our own iso with the packages we want.<\/p>\n<p>Before we start, you will want to make sure that your boot2docker is running with enough resources. The default should be 2048MB which should\u00a0work, you will also need enough disk space on \/var\/lib\/docker\/aufs inside boot2docker. \u00a0If you have problems consider\u00a0<a href=\"https:\/\/github.com\/boot2docker\/boot2docker-cli\/blob\/master\/README.md#configuration\" target=\"_blank\">changing your configuration<\/a>.<\/p>\n<p>Create a Dockerfile with the following contents:<\/p>\n<p><span style=\"color: #008000;\"><code>FROM boot2docker\/boot2docker<\/code><\/span><\/p>\n<p><span style=\"color: #008000;\"><code># Append indicator this is modified image<br \/>\nRUN echo \"\\nMy modified boot2docker.iso\\n\" &gt;&gt; $ROOTFS\/etc\/motd<br \/>\n<\/code><\/span><\/p>\n<p><span style=\"color: #008000;\"><code># Install perl5<br \/>\nRUN curl -L -o \/tmp\/perl5.tcz $TCL_REPO_BASE\/tcz\/perl5.tcz &amp;&amp; \\<br \/>\nunsquashfs -f -d $ROOTFS \/tmp\/perl5.tcz &amp;&amp; \\<br \/>\nrm -rf \/tmp\/perl5.tcz<br \/>\n<\/code><\/span><\/p>\n<p><span style=\"color: #008000;\"><code># build the iso<br \/>\nRUN \/make_iso.sh<br \/>\nCMD [\"cat\", \"boot2docker.iso\"]<\/code><\/span><\/p>\n<p>Then follow the boot2docker.iso <a href=\"https:\/\/github.com\/boot2docker\/boot2docker\/blob\/master\/doc\/BUILD.md#making-your-own-customised-boot2docker-iso\" target=\"_blank\">build process<\/a>.<\/p>\n<p><code>$ sudo docker build -t my-boot2docker-img .<br \/>\n$ sudo docker run --rm my-boot2docker-img &gt; boot2docker.iso<\/code><\/p>\n<p>The <code>FROM<\/code> is used to declare the base image we want to start from. We&#8217;re building\u00a0our new container on this base.<\/p>\n<p>The <code>RUN<\/code> directive is executed against the current image at build time. In this case we can&#8217;t use <code>tce-load<\/code> since we&#8217;re not actually running Tiny Core Linux at this point, we&#8217;re running against the docker image we are building. This is why we&#8217;re doing the installation of perl\u00a0manually. I based the installation from the <a href=\"https:\/\/github.com\/boot2docker\/boot2docker\/blob\/master\/Dockerfile#L117\" target=\"_blank\">boot2docker DockerFile<\/a>.<\/p>\n<p>The last two steps &#8220;build\u00a0the iso&#8221; are lifted directly from the same boot2docker Dockerfile, these are the steps required to actually\u00a0create the iso file.<\/p>\n<p>Figuring out how to run the boot2docker.iso I&#8217;ll leave as an exercise for the reader.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker\u00a0is seeing rapid adoption among the software development world. So far it seems to me a very nice way to make software installation much less painful, but there\u00a0is still plenty of room for improvement. If you&#8217;re running Linux then you can stop reading now.\u00a0Docker\u00a0is an abstraction layer over Linux Containers (LXC), they&#8217;ve also created a &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2015\/modify-boot2docker-iso\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Adding a package to boot2docker&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14],"tags":[],"class_list":["post-1467","post","type-post","status-publish","format-standard","hentry","category-how-to","category-work"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=1467"}],"version-history":[{"count":5,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1467\/revisions"}],"predecessor-version":[{"id":1474,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1467\/revisions\/1474"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=1467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=1467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=1467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}