Public Repository

Last pushed: 2 years ago
Short Description
如何產生
Full Description

#!/usr/bin/env bash

//尋找 busybox目錄

BUSYBOX=$(which busybox)

[ "$BUSYBOX" ] || {

echo "Sorry, I could not locate busybox."

echo "Try 'apt-get install busybox-static'?"

exit 1

}

//生成root目錄

set -e

ROOTFS=${TMPDIR:-/var/tmp}/rootfs-busybox-$$-$RANDOM

mkdir $ROOTFS

cd $ROOTFS

//拷貝本機檔案 進入root目錄

mkdir bin etc dev dev/pts lib proc sys tmp

touch etc/resolv.conf

cp /etc/nsswitch.conf etc/nsswitch.conf

echo root:x:0:0:root:/:/bin/sh > etc/passwd

echo root:x:0: > etc/group

ln -s lib lib64

ln -s bin sbin

cp $BUSYBOX bin

for X in $(busybox --list)

do

ln -s busybox bin/$X

done

rm bin/init

ln bin/busybox bin/init

cp /lib/x8664-linux-gnu/lib{pthread,c,dl,nsl,nss}.so. lib

cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib

for X in console null ptmx random stdin stdout stderr tty urandom zero

do

cp -a /dev/$X dev

done

mkdir www

echo "#!/bin/sh" > bin/httpd.sh

//啟動web server 家目錄為www

echo "httpd -p 80 -h /www" >> bin/httpd.sh

echo "/bin/sh" >> bin/httpd.sh

chmod +x bin/httpd.sh

//壓縮目前目錄 |(pipe line 輸送)到 docker 產生 qoochung/busybox images

tar --numeric-owner -cf- . | docker import - qoochung/busybox

Docker Pull Command
Owner
qoochung

Comments (0)