[docker] 构建镜像
时间:2021-04-10 16:10:59
收藏:0
阅读:15
#!/bin/bash
binfile=$1
currdir=$(cd $(dirname $0)/; pwd)
dstdir=$currdir/root/
if [ -z "$binfile" -o ! -e "$binfile" ]; then
echo "need arguments"
else
libs=$(ldd $binfile | grep ‘/lib‘ | sed -e "s,^\s*[^/]\+[^/]*[/],/,g" -e "s,(.*),,g")
echo "$libs" | while read line; do
echo "... $line"
libdir=$(dirname $line)
mkdir -vp $dstdir/$libdir
cp -vf $line $dstdir/$libdir/.
done
tmpdir=$(dirname $binfile)
mkdir -vp $dstdir/$tmpdir
cp -vf $binfile $dstdir/$tmpdir/.
fi
FROM scratch
COPY ./root /
ENV PATH="/bin"
./copybin.sh /bin/ls
./copybin.sh /bin/bash
docker build -t myimage .
docker run -it myimage bash
原文:https://www.cnblogs.com/timlinux/p/14640242.html
评论(0)