├── .gitignore ├── Dockerfile ├── README.md ├── mkrootfs.sh ├── rootfs.tar ├── tarmaker-buildroot ├── Dockerfile └── rootfs.tar └── tarmaker-ubuntu ├── Dockerfile └── rootfs.tar /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | MAINTAINER Jérôme Petazzoni 3 | ADD rootfs.tar / 4 | CMD ["/bin/sh"] 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jpetazzo's Busybox Image Builders 2 | 3 | *A.k.a. "The Little Containers That Could!"* 4 | 5 | This repository contains: 6 | 7 | - a `rootfs.tar` archive suitable to build a minimal [Docker] image, 8 | based on [Busybox]; 9 | - a `Dockerfile` referencing this tarball, suitable for inclusion into 10 | [Stackbrew]; 11 | - multiple subdirectories providing `Dockerfiles` to build this tarball. 12 | 13 | The goal of the latter is to solve a difficult question, *id est* 14 | "who builds the builders?". 15 | 16 | Those meta-builders are called "tarmakers". They obey the following "API": 17 | 18 | - they are built with a Dockerfile themselves; 19 | - the Dockerfile doesn't use any local content (no `ADD` of local file); 20 | - they generate `rootfs.tar` in their root directory. 21 | 22 | The script `mkrootfs.sh` is a helper to build `rootfs.tar`. It requires 23 | as first and only argument the name of a subdirectory containing a tarmaker. 24 | 25 | The following tarmakers are available: 26 | 27 | - buildroot: uses the [Buildroot] toolchain to compile everything from 28 | scratch (**WARNING: THIS IS SLOW**, it takes half an hour on my quad-core 29 | laptop with badass SSDs, so it will probably take a few hours in a typical 30 | VM!) 31 | - ubuntu: installs the `busybox-static` Ubuntu package and use it as the 32 | base for the newly built image. This is very fast but the resulting 33 | image is a bit bigger, because we have to slap a few fat greasy libraries 34 | on top of it. Would you like some fries with that? 35 | 36 | 37 | ## To rebuild a busybox image using one tarmaker or the other... 38 | 39 | ``` 40 | # Use buildroot or ubuntu 41 | TARMAKER=ubuntu 42 | ./mkrootfs.sh tarmaker-ubuntu 43 | docker build -t busybox . 44 | docker run -t -i busybox 45 | ``` 46 | 47 | 48 | [Buildroot]: http://buildroot.uclibc.org/ 49 | [Busybox]: http://www.busybox.net/ 50 | [Docker]: http://docker.io/ 51 | [Stackbrew]: https://github.com/dotcloud/stackbrew -------------------------------------------------------------------------------- /mkrootfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ "$1" ] || { 3 | echo "Specify tarmaker directory to use:" 4 | ls -1 -d tarmaker-* 5 | exit 1 6 | } 7 | [ -d "$1" ] || { 8 | echo "Could not find directory $1." 9 | exit 1 10 | } 11 | docker build -t tarmaker $1 || { 12 | echo "Something went wrong when building the builder. Aborting." 13 | exit 1 14 | } 15 | [ -f $1/rootfs.tar ] && mv $1/rootfs.tar $1/rootfs.tar.old 16 | docker run tarmaker cat /rootfs.tar > $1/rootfs.tar 17 | rm -f rootfs.tar 18 | # We use cp rather than ln because ln doesn't work well on VBox shared folders. 19 | cp $1/rootfs.tar rootfs.tar 20 | ls -ltr rootfs.tar */rootfs.tar* 21 | echo "You can now build the busybox image, with:" 22 | echo "docker build -t busybox ." 23 | -------------------------------------------------------------------------------- /rootfs.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpetazzo/docker-busybox/83cfcdf9f35c0e9140c77f769cbecb7b87509b68/rootfs.tar -------------------------------------------------------------------------------- /tarmaker-buildroot/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | # This will make it easier to upgrade to the next version of buildroot. 3 | # You might have to also update the busybox version at the end of this file! 4 | ENV BUILDROOT_VERSION 2015.02 5 | # This will get rid of a build warning related to 'tput'. 6 | ENV TERM dumb 7 | RUN apt-get update -q 8 | RUN apt-get install -qy wget build-essential libncurses-dev rsync unzip bc 9 | # Buildroot needs Python. Let's git it! 10 | RUN which python || ln /usr/bin/python3 /usr/bin/python 11 | # Let's make wget output a bit less verbose. 12 | RUN echo progress = dot:mega > /.wgetrc 13 | RUN wget http://buildroot.uclibc.org/downloads/buildroot-$BUILDROOT_VERSION.tar.gz 14 | # Check that we got the right tarball (update this when upgrading buildroot!) 15 | RUN echo "d1559c7651982d62be3544561f1cb81b buildroot-$BUILDROOT_VERSION.tar.gz" > buildroot.md5 16 | RUN md5sum --check buildroot.md5 17 | RUN tar -zxf buildroot-$BUILDROOT_VERSION.tar.gz 18 | # This symlink is because WORKDIR doesn't expand $VARS. 19 | RUN ln -s buildroot-$BUILDROOT_VERSION buildroot 20 | WORKDIR /buildroot 21 | RUN make defconfig 22 | RUN sed -i "s/BR2_i386=y/# BR2_i386 is not set/" .config 23 | RUN for CFGVAR in \ 24 | BR2_x86_64 \ 25 | BR2_TOOLCHAIN_BUILDROOT_LARGEFILE \ 26 | BR2_TOOLCHAIN_BUILDROOT_INET_IPV6 \ 27 | BR2_TOOLCHAIN_BUILDROOT_WCHAR \ 28 | BR2_PACKAGE_BRIDGE_UTILS \ 29 | BR2_PACKAGE_IPROUTE2 \ 30 | BR2_PACKAGE_IPTABLES \ 31 | ; do sed -i "s/# $CFGVAR is not set/$CFGVAR=y/" .config ; done 32 | RUN for CFGVAR in \ 33 | CONFIG_NC \ 34 | CONFIG_NC_SERVER \ 35 | CONFIG_NC_EXTRA \ 36 | CONFIG_BRCTL \ 37 | CONFIG_PING6 \ 38 | CONFIG_FEATURE_IPV6 \ 39 | CONFIG_FEATURE_IFUPDOWN_IPV6 \ 40 | # The below feature will prefer an IPv4 address over IPv6 from DNS to handle the 41 | # original problem regarding nc using the AAAA record if it exists 42 | CONFIG_FEATURE_PREFER_IPV4_ADDRESS \ 43 | CONFIG_FEATURE_BRCTL_FANCY \ 44 | CONFIG_FEATURE_BRCTL_SHOW \ 45 | CONFIG_FEATURE_BASH_IS_ASH \ 46 | ; do sed -i "s/# $CFGVAR is not set/$CFGVAR=y/" package/busybox/busybox.config ; done 47 | RUN make olddefconfig 48 | RUN make 49 | RUN ln -s /buildroot/output/images/rootfs.tar /rootfs.tar 50 | -------------------------------------------------------------------------------- /tarmaker-buildroot/rootfs.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpetazzo/docker-busybox/83cfcdf9f35c0e9140c77f769cbecb7b87509b68/tarmaker-buildroot/rootfs.tar -------------------------------------------------------------------------------- /tarmaker-ubuntu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | RUN apt-get update -q 3 | RUN apt-get install -qy busybox-static 4 | RUN mkdir /rootfs 5 | WORKDIR /rootfs 6 | RUN mkdir bin etc dev dev/pts lib proc sys tmp 7 | RUN touch etc/resolv.conf 8 | RUN cp /etc/nsswitch.conf etc/nsswitch.conf 9 | RUN echo root:x:0:0:root:/:/bin/sh > etc/passwd 10 | RUN echo root:x:0: > etc/group 11 | RUN ln -s lib lib64 12 | RUN ln -s bin sbin 13 | RUN cp /bin/busybox bin 14 | RUN $(which busybox) --install -s bin 15 | RUN bash -c "cp /lib/x86_64-linux-gnu/lib{c,m,dl,rt,nsl,nss_*,pthread,resolv}.so.* lib" 16 | RUN cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib 17 | RUN tar cf /rootfs.tar . 18 | RUN for X in console null ptmx random stdin stdout stderr tty urandom zero ; do tar uf /rootfs.tar -C/ ./dev/$X ; done 19 | -------------------------------------------------------------------------------- /tarmaker-ubuntu/rootfs.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpetazzo/docker-busybox/83cfcdf9f35c0e9140c77f769cbecb7b87509b68/tarmaker-ubuntu/rootfs.tar --------------------------------------------------------------------------------