How to use Docker to build enterprise-level custom images

How to use Docker to build enterprise-level custom images

Preface

Before leaving get off work, the author received a request. Due to changes in the basic image standard, it is necessary to build a custom image of his own application according to the latest Docker image standard. The current standard is this: the infrastructure group only provides three public images that all projects must access. These three public basic images include: JDK8, Skywalking, and Arthas. If other images need to be added to the applications of each business group, each business group will add its own custom image based on the public image provided by the infrastructure group. The structure diagram is as follows:

Build steps

Writing a Dockerfile

Based on the latest specifications, we need to write a Dockerfile, then reference the base image provided by the infrastructure group, and then add other images required by the application. So the final Dockerfile is as follows:

FROM base image address RUN apk add custom image to be added...

Install Docker environment under Centos7

Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these programs are installed, uninstall them and their associated dependencies.

$ sudo yum remove docker \
     docker-client \
     docker-client-latest \
     docker-common \
     docker-latest \
     docker-latest-logrotate \
     docker-logrotate \
     docker-engine

Install Docker Engine-Community

Install using Docker repository

Before installing Docker Engine-Community for the first time on a new host, you need to set up the Docker repository. Afterwards, you can install and update Docker from the repository.

Setting up a warehouse

Install the required packages. yum-utils provides yum-config-manager, and the device mapper storage driver requires device-mapper-persistent-data and lvm2.

$ sudo yum install -y yum-utils \
 device-mapper-persistent-data \
 lvm2

Use the following command to set up the stable repository.

$ sudo yum-config-manager \
 --add-repo \
 https://download.docker.com/linux/centos/docker-ce.repo

Install Docker Engine-Community

Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:

$ sudo yum install docker-ce docker-ce-cli containerd.io

If prompted to accept the GPG key, select Yes.

Are there multiple Docker repositories?

If multiple Docker repositories are enabled, installing or updating without specifying a version in a yum install or yum update command will always install the highest version, which might not be suitable for your stability needs.

Docker is not started by default after installation. The docker user group has been created, but there are no users in this user group.

To install a specific version of Docker Engine - Community, list the available versions in the repository, then select and install:

1. List and sort the versions available in your repository. This example sorts the results by version number (highest to lowest).

$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable

2. Install a specific version by its full package name, which is the package name (docker-ce) plus the version string (the second column) from the first colon (:) up to the first hyphen, separated by hyphens (-). For example: docker-ce-18.09.1.

$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

Start Docker.

$ sudo systemctl start docker

Verify that Docker Engine - Community is installed correctly by running the hello-world image.

$ sudo docker run hello-world

Start building custom application images

Build a custom image based on the Dockerfile file

Execute the following command in the directory where the Dockerfile file is located to build a custom image:

sudo docker build -f Dockerfile -t your custom image name.

Log in before pushing to the enterprise's private mirror harbor

docker login Enterprise private harbor address Enter username and password to complete login

Push the built custom image to the enterprise's private harbor

sudo docker push your custom image name

Summarize

Through the above four steps, we have completed the construction of the custom image of the application. We can directly use the custom image in our own application later. The advantage of doing this is that based on the basic image, we can freely combine it to build an image that meets our own application, which is more flexible, hierarchical management of images, and scalable.

This is the end of this article about how to use Docker to build enterprise-level custom images. For more information about how to use Docker to build enterprise-level custom images, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of Dockerfile to create a custom Docker image and comparison of CMD and ENTRYPOINT instructions
  • How to build php7 with docker custom image
  • Detailed explanation of custom configuration of docker official mysql image

<<:  Vue ElementUI Form form validation

>>:  MySQL 8.0.19 winx64 installation tutorial and change the initial password under Windows 10

Recommend

How to convert rows to columns in MySQL

MySQL row to column operation The so-called row-t...

CSS shadow animation optimization tips

This technique comes from this article - How to a...

MySQL 5.7.21 installation and configuration method graphic tutorial (window)

Install mysql5.7.21 in the window environment. Th...

Vue implements login type switching

This article example shares the specific code of ...

Detailed explanation of this pointing problem in JavaScript function

this keyword Which object calls the function, and...

MySQL can actually implement distributed locks

Preface In the previous article, I shared with yo...

Detailed tutorial on installing CentOS, JDK and Hadoop on VirtualBox

Table of contents 1. Prerequisites 1.1 Supported ...

Summary of Vue 3 custom directive development

What is a directive? Both Angular and Vue have th...

Let's take a look at some powerful operators in JavaScript

Table of contents Preface 1. Null coalescing oper...

A complete explanation of MySQL high availability architecture: MHA architecture

Table of contents 1. Introduction 2. Composition ...

A Different Kind of "Cancel" Button

The “Cancel” button is not part of the necessary ...

Detailed explanation of the correct use of the count function in MySQL

1. Description In MySQL, when we need to get the ...

Operate on two columns of data as new columns in sql

As shown below: select a1,a2,a1+a2 a,a1*a2 b,a1*1...

Three ways to achieve background blur in CSS3 (summary)

1. Normal background blur Code: <Style> htm...