The docker-maven-plugin plugin sets Docker's buildArgs

docker-maven-plugin is a docker plug-in for spring boot projects produced by spotify, which can package spring boot projects into docker images.

If you need to set the build arg when compiling the docker image, you only need to add buildArgs under the configuration in the maven configuration file pom.xml. The key and value of the tag correspond to the key and value of the build arg. As shown below, during the docker image compilation process, there will be a build arg named ARG_TIME_ZONE, and its value will be the OS environment variable TIME_ZONE.

  <build>
    <plugins>
      <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.4.13</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <imageName>${docker.registry.name}/${project.artifactId}:latest</imageName>
          <dockerDirectory>src/main/docker</dockerDirectory>
          <buildArgs>
            <ARG_TIME_ZONE>${env.TIME_ZONE}</ARG_TIME_ZONE>
          </buildArgs>
          <resources>
            <resource>
              <targetPath>/</targetPath>
              <directory>${project.build.directory}</directory>
              <include>${project.build.finalName}.jar</include>
            </resource>
          </resources>
        </configuration>
      </plugin>
    </plugins>
  </build>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324376927&siteId=291194637