Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to self-make docker Image

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to make your own docker images. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1 use the existing ISO image to make a basic image, taking ubuntu14.04 as an example

Mount-o loop ubuntu-14.04-server-amd64.iso / media/cdrom tar-C / media/cdrom-c. | | docker import-guol / ubuntu14 |

In this way, you can make a basic image, but this image is very large and contains some software that we don't need. If you want to cut it, you can use the chroot command to enter the basic image and delete some software packages.

2 debian/ubuntu series has a tool debootstrap, which can be used to make smaller images, but also has 300m, which can modify the build script and crop. Take ubuntu14.04 as an example.

Debootstrap-variant=buildd-arch=amd64 trusty trusty http: / / mirrors .163.com / ubuntu/ tar-C trusty-c. | | docker import-trusty |

Note: how to use debootstrap

Debootstrap [OPTION...] SUITE TARGET [MIRROR [SCRIPT]]

SUITE is the name of some linux distributions, which can only be used by the linux distribution build scripts in the / usr/share/debootstrap/scripts/ directory by default. The default debootstrap is built on these scripts.

MIRROR is generally built using the official source by default, which is slow and is generally replaced with a domestic source. This source is set in the build script of / usr/share/debootstrap/scripts/ by default and is directly added to the command line to override the settings inside.

SCRIPT debootstrap is based on what script to build the image. The default is the one in the / usr/share/debootstrap/scripts/ directory, or you can write it yourself.

3 use the official build script, which is available in the official source code on github.

Git clone https: / / github .com / dotcloud/docker .git cd docker / contrib

Let's see what's in the downloaded source code and enter the contrib directory.

You can see a lot of image build scripts, according to your operating system to choose the script, I use mkimage-debootstrap.sh, but there is a problem is using the built-in script to install the script only supports debian6 ubuntu12, because the script is only specified in these two distributions, but you can manually modify the script to support more distributions. The script creates a temporary directory under the / tmp directory to build the image, automatically import after successful construction, and then automatically deletes the build directory. The resulting image is about 180m smaller.

. / mkimage-debootstrap .sh ubuntu12 precise http: / / mirrors .sohu.com / ubuntu/

You can see that the image is made automatically and submitted automatically.

5-22

Docker update is really fast. Today, git downloaded the latest source code and found that mkimage-debootstrap.sh already supports ubuntu14.04, but the script will be abandoned in the future. Officials suggest using mkimage.sh scripts in the same directory to build images.

Thank you for reading! This is the end of the article on "how to make a docker Image". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report