http://www.oschina.net/news/62897/docker-hub-contains-high-risk-vulnerabilities 這裏有個統計,docker官方和我的發佈的鏡像因爲版本等各類緣由,漏洞較多,那咱們如何本身從頭開始作個定製的鏡像呢?linux
對,找官方文檔 http://docs.docker.com/articles/baseimages/,這裏說明的很清楚了git
試驗以下:在centos7機器上作centos鏡像github
直接參考這個腳本docker
https://raw.githubusercontent.com/docker/docker/master/contrib/mkimage-yum.shcentos
./mkimage-yum.sh -y /etc/yum.conf centos7安全
執行如上腳本,成功後,就能夠看到鏡像了【docker images】,概要說明一下,主要是以下幾步:dom
1.tmp目錄下創建臨時目錄和文件系統centos7
2.使用yum安裝相關的軟件包spa
3.軟件包安裝和信息定製.net
4.tar打包
5.清理
target=(mktemp−d−−tmpdir(basename $0).XXXXXX)
set -x
mkdir -m 755 "$target"/dev
mknod -m 600 "$target"/dev/console c 5 1
mknod -m 600 "$target"/dev/initctl p
mknod -m 666 "$target"/dev/full c 1 7
mknod -m 666 "$target"/dev/null c 1 3
mknod -m 666 "$target"/dev/ptmx c 5 2
mknod -m 666 "$target"/dev/random c 1 8
mknod -m 666 "$target"/dev/tty c 5 0
mknod -m 666 "$target"/dev/tty0 c 4 0
mknod -m 666 "$target"/dev/urandom c 1 9
mknod -m 666 "$target"/dev/zero c 1 5
# amazon linux yum will fail without vars set
if [ -d /etc/yum/vars ]; then
mkdir -p -m 755 "$target"/etc/yum
cp -a /etc/yum/vars "$target"/etc/yum/
fi
yum -c "yumconfig"−−installroot="target" --releasever=/ --setopt=tsflags=nodocs \
--setopt=group_package_types=mandatory -y groupinstall Core
yum -c "yumconfig"−−installroot="target" -y clean all
...
tar --numeric-owner -c -C "target".|dockerimport−name:$version
docker run -i -t name:version echo success
rm -rf "$target"
若是咱們須要本身的安全加強軟件等定製,只須要在第2步將咱們的內容合併進去便可
生成的鏡像能夠做爲咱們工做的基礎,固然你也能夠push到開源社區