Production docker base image

The mirror base 1. reposync synchronized to a local library

-Y-utils the install yum yum the createrepo 
mkdir -p / Data / centos7 
Find /etc/yum.repos.d/[!.]* Music Videos -exec {} {} .bak \; 
CAT << the EOF> / etc / yum .repos.d / sync.repo 
[Base] 
name = aliyun-centos7 
Enabled. 1 = 
BaseURL = HTTPS: //mirrors.aliyun.com/centos/7/os/x86_64/ 
gpgcheck = 0 
the EOF 
yum Clean All 
the nohup reposync - Base-only --repoid = Newest -p / Data / centos7 /> / dev / null 2> &. 1 & 
the createrepo / Data / centos7 / Base -o / Data / centos7 / Base 
wget https://mirrors.aliyun.com/ CentOS / RPM-GPG-KEY-CentOS-7 -P / the Data / centos7 
# Note: reposync command a regular basis to ensure that local sources are up to date.

2. Install docker

wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce
mkdir -p /etc/docker
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl daemon-reload && systemctl enable docker && systemctl restart docker
docker version

3. Make a scratch empty mirror

tar cf scratch.tar --files-from /dev/null
docker import scratch.tar scratch
或者
docker rmi scratch
tar cv --files-from /dev/null | docker import - scratch
#备注:减号是标准输出,将管道前面命令的执行结果放入减号位置。

4. Make the root centos7.5 centos7.5 operating system command line and packaged

mkdir /root/vroot
yum -y install --installroot=/root/vroot bash yum coreutils
chroot /root/vroot/
cp /etc/skel/.[!.]* /root/
ls -a /root
exit
chroot /root/vroot/
exit
tar -cJf centos-7-docker.tar.xz -C vroot ./

5. Production of docker mirror centos7.5

mkdir /root/mydocker
mv centos-7-docker.tar.xz /root/mydocker/
cd /root/mydocker/
echo 'FROM scratch
ADD centos-7-docker.tar.xz /

LABEL org.label-schema.schema-version = "1.0" \
    org.label-schema.name="CentOS Base Image" \
    org.label-schema.vendor="CentOS" \
    org.label-schema.license="GPLv2" \
    org.label-schema.build-date="20190716"

CMD ["/bin/bash"]'  >  Dockerfile
docker build -t centos:latest .
docker images centos
docker history centos

6. Run just made centos mirror and change back out of the container

docker run -it centos
ifconfig
yum provides ifconfig
yum -y install net-tools
ifconfig
pstree
yum provides pstree
yum -y install psmisc
pstree -p
ls /
exit
docker container ls -a
docker save centos -o /root/centos.tar
tar -tvf /root/centos.tar
#备注:docker save导出的文件,其实就是一个普通的压缩文件,
这个压缩文件中包含了镜像的所有镜像层,以及包含镜像基本信息的Manifest文件。
在Manifest文件中,包含了所有镜像层的散列值,可以通过这些特征值来检查镜像层文件是否完整且正确。

7. Start the container vessel and exit the right way

docker ps -a
docker start ee6286a3d32f
docker attach ee6286a3d32f 
ctrl+p+q
docker ps

Guess you like

Origin blog.51cto.com/14296289/2421172