说明:根据youtube视屏学习,视屏网址:https://www.youtube.com/watch?v=s948NKa1I1I&noredirect=1
1、在虚拟机上安装minimal版本的系统(centos6.5)虚拟机网络保证是NAT模式,这样可以能使用在线yum源
2、配置虚拟机网络环境:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
------------------------------------------------------------
ifup eth0
yum install vim #测试yum是否可用,vim安装后方便后期脚本编辑
3、安装epel-release rpm包,下面网址中提供各种操作系统的包
http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
----------------------------------------------------------------
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
4、修改/etc/yum.repos.d/CentOS-Base.repo
----------------------------------------------------------------
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
----------------------------------------------------------------
yum update -y #软件升级,主要是内核过低会导致高版本的docker无法启动
yum install docker-io #安装docker,这里的版本是1.7.1
:%s/$releasever/6/g
:%s/$basearch/x86_64/g
5、在/root/下面
mkdir scripts
touch mkimage-yum.sh
拷贝https://github.com/docker/docker/blob/master/contrib/mkimage-yum.sh
内容到脚本中
chmod +x mkimage-yum.sh
./mkimage_yum.sh centos6.8image
[root@localhost scripts]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos6.8image 6.8 ec9c8e39b9c6 26 seconds ago 183.2 MB
导出镜像:
[root@localhost scripts]# docker save ec9c8e39b9c6 > ./centos6.8base.tar
本地加载:
docker load < /home/paradigm/project/docker_note/images/centos6.8base.tar
镜像打标:
docker tag 4218ea8f4b45 4paradigm/centos:6.8
1、在虚拟机上安装minimal版本的系统(centos6.5)虚拟机网络保证是NAT模式,这样可以能使用在线yum源
2、配置虚拟机网络环境:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
------------------------------------------------------------
ifup eth0
yum install vim #测试yum是否可用,vim安装后方便后期脚本编辑
3、安装epel-release rpm包,下面网址中提供各种操作系统的包
http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
----------------------------------------------------------------
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
4、修改/etc/yum.repos.d/CentOS-Base.repo
----------------------------------------------------------------
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
----------------------------------------------------------------
yum update -y #软件升级,主要是内核过低会导致高版本的docker无法启动
yum install docker-io #安装docker,这里的版本是1.7.1
:%s/$releasever/6/g
:%s/$basearch/x86_64/g
5、在/root/下面
mkdir scripts
touch mkimage-yum.sh
拷贝https://github.com/docker/docker/blob/master/contrib/mkimage-yum.sh
内容到脚本中
chmod +x mkimage-yum.sh
./mkimage_yum.sh centos6.8image
[root@localhost scripts]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos6.8image 6.8 ec9c8e39b9c6 26 seconds ago 183.2 MB
导出镜像:
[root@localhost scripts]# docker save ec9c8e39b9c6 > ./centos6.8base.tar
本地加载:
docker load < /home/paradigm/project/docker_note/images/centos6.8base.tar
镜像打标:
docker tag 4218ea8f4b45 4paradigm/centos:6.8