In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to build a docker image without installing docker". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to build a docker image without installing docker.
Premise
Docker
Container image repository
Here are two examples that can be shared.
Dockerhub
Ali Cloud Container Image Service
Preface
This paper mainly introduces jib. Google, an open source docker building tool in the field of java.
At present, the start on github has 8.5k fork and 784. it is a very convenient tool for building docker in java domain.
The highlight is that there is no need for Docker daemon, which means that docker images can be built through jib even if docker is not installed locally, and images that conform to OCI specifications can be built.
There are three official ways to support:
Maven plug-in
Grade plug-in
Jib code base
This article uses the springboot project to describe through the maven plug-in.
Let's talk about the third, jib code base, which can be used to build java docker services on our own platform.
Configure pom.xml
Add the following standard tag to the file
...
Com.google.cloud.tools
Jib-maven-plugin
2.0.0
Registry.cn-hangzhou.aliyuncs.com/dragonwell/dragonwell8:8.1.1-GA_alpine_x86_64_8u222-b67
ImageName
...
The above content is configured with a resulting image name imageName, that is, the resulting docker image address, including the container repository address / image name: version number, such as registry.cn-beijing.aliyuncs.com/lyp/lanbox:v1.0. If the repository address is left empty, it defaults to dockerhub.
In addition, a basic mirror registry.cn-hangzhou.aliyuncs.com/dragonwell/dragonwell8:8.1.1-GA_alpine_x86_64_8u222-b67 is configured, which can be considered equivalent to the From statement in Dockerfile.
If the basic image or target image requires an account password, you can add an authentication information to the from tag or to tag. There are three ways:
Configured in the configuration file of docker
Configured in setting.xml of maven
Configure directly in the pom.xml file
This article uses the third method, that is, to add an auth tag for authentication information under the from tag or to tag, for example:
...
Kafeidou
Kafeidou
...
It can also be easily configured by means of environment variables:
...
${env.REGISTRY_FROM_USERNAME}
${env.REGISTRY_FROM_PASSWORD}
...
The ${env.} part is fixed, followed by the actual environment variable.
You can also use system properties to:
Mvn compile jib:build\
-Djib.to.image=myregistry/myimage:latest\
-Djib.to.auth.username=kafeidou\
-Djib.to.auth.password=kafeidou
Isn't it convenient to pass authentication information through parameters during the build?
Continue to look at the label under configuration with container configuration:
This tag mainly configures the contents related to the target container, such as:
AppRoot-> place the root directory of the application for the war package project
Args-> extra startup parameters for the program.
Environment-> environment variables for containers
Format-> build an image of the OCI specification
JvmFlags-> JVM parameters
MainClass-> program startup class
Ports-> Container Open Port
...
There are other details that can be found in https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#container-object..
It is important to note that Ali's container image service does not support OCI image, so if you choose to use Ali's container image service, remember to cancel the OCI format. It is cancelled by default.
In addition, JVM parameters can be configured with dynamic content through environment variables, so there is no need to plan to write all startup parameters in the jvmFlags tag.
For example, when starting the container, specify a G 1 recycler, docker run-it-e JAVA_TOOL_OPTIONS= "- XX:+UseG1GC"-d registry.cn-beijing.aliyuncs.com/lyp/lanbox:v1.0.
After all the configuration items are completed, run the mvn command mvn compile jib:build to start building the docker image.
If you see a message like this, it's a success:
[INFO]
[INFO] BUILD SUCCESS
[INFO]
[INFO] Total time: 42.598 s
INFO] Finished at: 2020-02-18T23:30:53+08:00
[INFO]
At this point, I believe you have a deeper understanding of "how to build a docker image without installing docker". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.