github.com/nguyentm83/docker@v1.5.0/contrib/mkimage-busybox.sh (about) 1 #!/usr/bin/env bash 2 # Generate a very minimal filesystem based on busybox-static, 3 # and load it into the local docker under the name "busybox". 4 5 echo >&2 6 echo >&2 'warning: this script is deprecated - see mkimage.sh and mkimage/busybox-static' 7 echo >&2 8 9 BUSYBOX=$(which busybox) 10 [ "$BUSYBOX" ] || { 11 echo "Sorry, I could not locate busybox." 12 echo "Try 'apt-get install busybox-static'?" 13 exit 1 14 } 15 16 set -e 17 ROOTFS=${TMPDIR:-/var/tmp}/rootfs-busybox-$$-$RANDOM 18 mkdir $ROOTFS 19 cd $ROOTFS 20 21 mkdir bin etc dev dev/pts lib proc sys tmp 22 touch etc/resolv.conf 23 cp /etc/nsswitch.conf etc/nsswitch.conf 24 echo root:x:0:0:root:/:/bin/sh > etc/passwd 25 echo root:x:0: > etc/group 26 ln -s lib lib64 27 ln -s bin sbin 28 cp $BUSYBOX bin 29 for X in $(busybox --list) 30 do 31 ln -s busybox bin/$X 32 done 33 rm bin/init 34 ln bin/busybox bin/init 35 cp /lib/x86_64-linux-gnu/lib{pthread,c,dl,nsl,nss_*}.so.* lib 36 cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib 37 for X in console null ptmx random stdin stdout stderr tty urandom zero 38 do 39 cp -a /dev/$X dev 40 done 41 42 tar --numeric-owner -cf- . | docker import - busybox 43 docker run -i -u root busybox /bin/echo Success.