How does docker images build its own native mirror
- 2020-06-12 11:18:06
- OfStack
How does docker images build its own native mirror
Making the image native image requires the febootstrap tool. Note that in the centos7 series, this package is not included in the default source, but in the centos6 series, it is available by default.
Install febootstrap in centos6
# yum install febootstrap -y
The appropriate packages are installed: fakechroot-2.9-24.5.el6_1.1.x86_64.rpm
, fakechroot-libs-2.9-24.5.el6_1.1.x86_64.rpm
fakeroot-1.12.2-22.2.el6.x86_64.rpm fakeroot-libs-1.12.2-22.2.el6.x86_64.rpm
febootstrap-supermin-helper-3.21-4.el6.x86_64.rpm
And that will produce 1 A command febootstrap
Use febootstrap tools to build base images:
#febootstrap -i bash -i wget -i yum -i iputils -i iproute centos6.8 centos6.8-doc http://mirrors.163.com/centos/6.8/os/x86_64/
Note that the -ES22en parameter represents the installation package, es23EN6.8 is the image version, centos6.8-ES26en is the directory where the image is generated, and url is the source address of the image.
The build is then completed and a base image is generated:
# ls centos6.8-doc
bin boot dev etc home lib lib64 media mnt opt proc root sbin selinux srv sys tmp usr var
You can see that the generated centos6.8-ES35en directory already contains the basic file system for the linux system. Generating such a directory is essentially a basic linux image that needs to be packaged and distributed to the docker host and built into the corresponding docker image.
Import this image using the docker tool:
In whatever environment, first go to the centos6.8-ES48en directory and then import the mirror:
# cd centos6.8-doc
# tar -c .|docker import - centos:6.8
f86315da0e5ddfdbc2aaf169d7f26cf9e071afb7df04bc207ff0d5b623221c8c
At this point, we have alpha 1 A mirror.
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos 6.8 f86315da0e5d 6 seconds ago 392.9 MB
Next, use this image to create and use containers:
# docker run -itd -P centos:6.8 bash
45fc3313c92f8ef8b1fe841da580ca0759b82e54a507c3985dc1c65d6106e12d
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45fc3313c92f centos:6.8 "bash" 20 seconds ago Up 19 seconds desperate_meitner
# docker exec -it desperate_meitner cat /etc/redhat-release
CentOS release 6.8 (Final)
You can see the current image The mirror is created at that time 6.8 Version of the
# docker exec -it desperate_meitner ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
311: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 02:42:0a:00:00:25 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.37/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::42:aff:fe00:25/64 scope link
valid_lft forever preferred_lft forever
At this point, a complete basic docker images is ready.
Thank you for reading, I hope to help you, thank you for your support to this site!