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

Super simple implementation of Docker to build a personal blog system

Install Docker Update the yum package to the late...

Solution to MySQL service 1067 error: modify the mysql executable file path

Today I encountered the MySQL service 1067 error ...

Learn MySQL in a simple way

Preface The database has always been my weak poin...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

Alibaba Cloud Ubuntu 16.04 builds IPSec service

Introduction to IPSec IPSec (Internet Protocol Se...

How to use the VS2022 remote debugging tool

Sometimes you need to debug remotely in a server ...

Native js canvas to achieve a simple snake

This article shares the specific code of js canva...

HTML form and the use of form internal tags

Copy code The code is as follows: <html> &l...

Detailed explanation of Vue3's sandbox mechanism

Table of contents Preface Browser compiled versio...

Best Practices Guide for MySQL Partitioned Tables

Preface: Partitioning is a table design pattern. ...

A permanent solution to MYSQL's inability to recognize Chinese

In most cases, MySQL does not support Chinese whe...

idea combines docker to realize image packaging and one-click deployment

1. Install Docker on the server yum install docke...

The benefits and examples of placing the site map at the bottom of the web page

In the past, almost every website had a sitemap p...

Singleton design pattern in JavaScript

Table of contents 1. What is a design pattern? 2....