基于debian系统的busybox容器镜像构建方法

#!/bin/bash
#安装busybox静态软件包
apt-get install -y busybox-static
rm -rf /tmp/rootfs
mkdir -p /tmp/rootfs
cd /tmp/rootfs
busybox=`which busybox`
#生成busybox文件系统
for module in `busybox --list-full`
do
        mkdir -p `dirname "$module"`
        ln -sf /bin/busybox "$module"
done
set -x
rm -rf bin/busybox
cp $busybox bin/

tar -czf busybox.tar.gz ./*
#生成做busybox的Dockerfile
tee Dockerfile <<-'EOF'
From scratch
ADD busybox.tar.gz /
CMD ["/bin/sh"]
EOF

cat Dockerfile
#构建busybox镜像
docker build -t busybox:v1 -f Dockerfile .
set +x
cd -
rm -rf /tmp/rootfs

猜你喜欢

转载自blog.csdn.net/qq_25650463/article/details/115735466