我正在尝试使用以下命令为 Maven 项目构建 docker 映像:mvn clean install -DskipTests -Pdocker
我有以下内容Dockerfile:
FROM openjdk:8-jre
ARG serviceuser=${project.artifactId}
##UPDATES AND INSTALL REQUIRED PACKAGES
RUN apt-get update && \
apt-get install -y gettext-base sudo && \
apt-get install -y iptables sudo && \
adduser --shell /bin/bash ${serviceuser} && \
adduser ${serviceuser} sudo && \
echo "%sudo ALL=NOPASSWD: ALL" >> /etc/sudoers
USER ${serviceuser}
##MOVE AND COPY PROJECT FILES INTO CONTAINER
COPY ${project.build.finalName}.jar /home/${serviceuser}/
WORKDIR /home/${serviceuser}
The pom.xml文件包含以下一些内容:(为了解释而将其缩短)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.book.app</groupId>
<artifactId>book-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>book-app</name>
<url>http://maven.apache.org</url>
<profiles>
<profile>
<id>docker</id>
<build>
<resources>
<resource>
<directory>docker</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.3</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<contextDirectory>${project.build.directory}</contextDirectory>
<repository>test-img:2000/v1/${project.artifactId}</repository>
<tag>${project.version}</tag>
<tag>latest</tag>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
<dependencies>
...
</dependencies>
<build>
...
</build>
</project>
当我构建时,它给我以下错误消息......
原因:com.spotify.docker.client.exceptions.DockerException:无法处理“${project.artifactId}”:替换中缺少“:”
[错误] 处理失败“${project.artifactId}”:替换中缺少 ':'
[信息] 构建失败
我将不胜感激任何提示或帮助,谢谢。
每当变量名称中包含某些非字母数字字符时,Docker 就会抛出此误导性错误。
我假设它试图将它们解释为指定 bash 样式的语法默认值替换 http://www.tldp.org/LDP/abs/html/parameter-substitution.html.
为了防止出现此错误,请从变量名称中删除该字符。
在你的例子中它是.
导致错误,对我来说这是一个-
我不得不用一个替换_
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)