Docker makes base image from scratch [CentOS]

Source: Internet
Author: User

Http://www.oschina.net/news/62897/docker-hub-contains-high-risk-vulnerabilities Here's a statistic,Docker . Official and individual release of the image due to a variety of reasons, such as the number of loopholes, how can we start from scratch to make a custom image?

Yes, look for the official document Http://docs.docker.com/articles/baseimages/, it's clear.

The test is as follows: Make a centos image on the centos7 Machine

Refer directly to this script

https://raw.githubusercontent.com/docker/docker/master/contrib/mkimage-yum.sh

./mkimage-yum.sh-y/etc/yum.conf Centos7

Execute the above script, after success, you can see the mirror "Docker images", outline, mainly the following steps:

1. Create temp directory and file system under TMP directory

2. Installing related packages with yum

3. Package Installation and Information customization

4. Tar packaging

5. Clean

Building the directory structure[Rootfs]

target=$ (mktemp-d--tmpdir $ (basename $). XXXXXX)

Set-x

Mkdir-m 755 "$target"/dev

Mknod-m "$target"/dev/console C 5 1

Mknod-m "$target"/dev/initctl p

Mknod-m 666 "$target"/dev/full C 1 7

Mknod-m 666 "$target"/dev/null C 1 3

Mknod-m 666 "$target"/DEV/PTMX C 5 2

Mknod-m 666 "$target"/dev/random C 1 8

Mknod-m 666 "$target"/dev/tty C 5 0

Mknod-m 666 "$target"/dev/tty0 C 4 0

Mknod-m 666 "$target"/dev/urandom C 1 9

Mknod-m 666 "$target"/dev/zero C 1 5

# Amazon Linux yum would fail without vars set

if [-d/etc/yum/vars]; Then

Mkdir-p-M 755 "$target"/etc/yum

Cp-a/etc/yum/vars "$target"/etc/yum/

Fi

Package Installation and Information customization

Yum-c "$yum _config"--installroot= "$target"--releasever=/--setopt=tsflags=nodocs \

--setopt=group_package_types=mandatory-y Groupinstall Core

Yum-c "$yum _config"--installroot= "$target"-y clean All

...

Packaged

Tar--numeric-owner-c-C "$target". | Docker import-$name: $version

Docker Run-i-T $name: $version Echo Success

Clean

Rm-rf "$target"

If we need our own security enhancement software and other customizations, we only need to merge our content in step 2 .

The resulting image can be used as a basis for our work, but you can also push to the open source community

Docker makes base image from scratch [CentOS]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.