CentOS 6.6和7.1 Docker自制CentOS鏡像docker
安裝:shell
yum -y install febootstrap
添加用戶:bootstrap
adduser admin
把admin用戶加到docker組:ubuntu
usermod -a -G docker admin
使用admin用戶操做centos
su admin cd /home/admin
使用root帳號製做鏡像,普通用戶製做後會有各類問題:bash
febootstrap -i bash -i wget -i yum -i iputils -i iproute centos66 centos66-doc http://mirrors.163.com/centos/6.6/os/x86_64/
(-i 安裝package, centos66 操做系統版本,centos66-doc安裝目錄,最後是源地址)ssh
上面成功後:測試
cd centos66-doc/ tar -c .|docker import - centos66-bash
(centos66-bash爲docker鏡像名字)centos7
執行:spa
docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos66-bash latest d2ecedd2b5ed 8 minutes ago 306.7 MB
測試docker鏡像,建立一個容器:
docker run -t -i centos66-bash /bin/bash
退出後
docker ps -a [admin@aleiye centos66-doc]$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 80548eb4275a centos66-bash:latest "/bin/bash" 2 hours ago Exited (0) About an hour ago focused_stallman
啓動剛纔建立的容器:
docker start 80548eb4275a
進入啓動後的容器:
docker attach 80548eb4275a
一個簡單的鏡像就製做完成了。
導出鏡像和導入鏡像方便分享鏡像文件
導出鏡像:
docker save IMAGENAME | bzip2 -9 -c>img.tar.bz2
導入鏡像(換一臺機器):
bzip2 -d -c <img.tar.bz2 | docker load
製做centos7.1鏡像
febootstrap -i bash -i wget -i apt-get -i iputils -i iproute -i openssh-server -i openssh-clients centos71 centos71-doc http://mirrors.163.com/centos/7.1.1503/os/x86_64 cd docker71-doc tar -c . | docker import - centos71-bash docker run -it centos71-bash /bin/bash exit [admin@aleiye centos71-doc]$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6413f67962ca centos71-bash:latest "/bin/bash" 16 seconds ago Exited (0) 11 seconds ago modest_payne
製做Ubuntu 14.10鏡像(失敗)
febootstrap -i bash -i wget -i apt-get -i iputils -i iproute ubuntu1410 ubuntu1410-doc http://mirrors.163.com/ubuntu-releases/14.10/
[admin@aleiye centos71-doc]$ febootstrap -i bash -i wget -i apt-get -i iputils -i iproute ubuntu1410 ubuntu1410-doc http://mirrors.163.com/ubuntu-releases/14.10/
設置安裝進程
http://mirrors.163.com/ubuntu-releases/14.10/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
嘗試其餘鏡像。
錯誤:Cannot retrieve repository metadata (repomd.xml) for repository: febootstrap. Please verify its path and try again
chroot: 沒法運行命令"rm": 沒有那個文件或目錄
chroot: 沒法運行命令"rm": 沒有那個文件或目錄
失敗,是須要debootstrap來製做嗎?