定义属性
<properties>
<!-- only compile isntall on dev , not tar docker -->
<skipDocker>false</skipDocker>
</properties>
设置插件是否跳过的属性
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<configuration>
<dockerHost>${docker.host}</dockerHost>
<registry>${docker.registry}</registry>
<authConfig>
<push>
<username>${docker.username}</username>
<password>${docker.password}</password>
</push>
</authConfig>
<images>
<image>
<name>${docker.registry}/${docker.namespace}/${project.name}:${project.version}</name>
<build>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
<contextDir>${project.basedir}/src/main/docker/</contextDir>
</build>
</image>
</images>
<skip>${skipDocker}</skip>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
运行命令
mvn clean install -DskipTests=true -DskipDocker=true