CentOS下febootstrap自制Docker的CentOS6.6和7.1 Docker镜像
CentOS 6.6和7.1 Docker自制CentOS镜像
安装:
1
|
yum -y install febootstrap |
添加用户:
1
|
adduser admin |
把admin用户加到docker组:
1
|
usermod -a -G docker admin |
使用admin用户操作
1
2
|
su admin cd /home/admin |
使用root账号制作镜像,普通用户制作后会有各种问题:
1
|
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安装目录,最后是源地址)
上面成功后:
1
2
|
cd centos66-doc/ tar -c .|docker import - centos66- bash |
(centos66-bash为docker镜像名字)
执行:
1
2
3
|
docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos66- bash latest d2ecedd2b5ed 8 minutes ago 306.7 MB |
测试docker镜像,创建一个容器:
1
|
docker run -t -i centos66- bash /bin/bash |
退出后
1
2
3
4
|
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 |
启动刚才创建的容器:
1
|
docker start 80548eb4275a |
进入启动后的容器:
1
|
docker attach 80548eb4275a |
一个简单的镜像就制作完成了。
导出镜像和导入镜像方便分享镜像文件
导出镜像:
1
|
docker save IMAGENAME | bzip2 -9 -c>img. tar .bz2 |
导入镜像(换一台机器):
1
|
bzip2 -d -c <img. tar .bz2 | docker load |
制作centos7.1镜像
1
2
3
4
5
6
7
8
|
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镜像(失败)
1
|
febootstrap -i bash -i wget -i apt-get -i iputils -i iproute ubuntu1410 ubuntu1410-doc http: //mirrors .163.com /ubuntu-releases/14 .10/ |
1
|
[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": 没有那个文件或目录