Automatically generate Dockerfile to build Docker image
[Copy link]
This post was last edited by liuyongsuse on 2020-12-6 00:55
You can build a Docker image by automatically generating a Dockerfile through the configuration of pom.xml without Dockerfile. The Dockerfile file needs to be placed in the project root directory, that is, at the same level as pom.xml.
Obviously, the official recommendation is the dockerfile-maven method that relies on Dockerfile. However, when installing a project, you only need to configure pom.xml to use docker-maven-plugin, and you don't need to modify external configurations, so it is more convenient and worry-free. The following will explain how to complete the image structure of these two methods one by one. You don't need Dockerfile, and you can simply automatically generate Dockerfile through the configuration of pom.xml to build a Docker image.
Relying on the Dockerfile file, it needs to be placed in the project root directory, that is, at the same level as pom.xml. Although the official recommendation is the Dockerfile-maven method that relies on Dockerfile, when installing the project, you only need to configure pom.xml and you don’t need to modify the external configuration, so it is more convenient and worry-free. The following will explain how to complete the image construction in these two methods one by one. The youlai-gateway gateway module is used for construction. The docker-maven-plugin method constructs the image.
|