【发布时间】:2021-01-07 19:02:50
【问题描述】:
我正在使用包含所有 maven 配置、密钥、maven 命令和所有内容的 sh 文件,我想从 Dockerfile 中执行这个 sh 文件,以便在我运行容器时执行 sh 文件。
这就是我的 Docker 文件的样子:
#using alpine jdk
FROM somewhere.docker.hub/build/alpine:latest AS fetch
#MVN as build tool
FROM somewhere.docker.hub/build/maven:3.5.3-jdk-8 AS build
#Settings.xml for downloading dependencies from nexus repository
ARG MVN_SETTINGS=settings.xml
#Defining the current working repository
WORKDIR /usr/src/app
#Coping the pom.xml into working directory
COPY pom.xml /usr/src/app
COPY ${MVN_SETTINGS} /usr/src/app/settings.xml
# Download the package and make it cached in docker image
#RUN mvn -B -f ./pom.xml -s settings.xml dependency:resolve
#Coping the source code into the working repository
COPY . /usr/src/app
#Run the sh file
#RUN chmod a+x /usr/src/app/DockerTest.sh
# Not using the full path of DockerTest.sh file because it is already in the work directory as defined above
RUN chmod a+x DockerTest.sh
DockerTest.sh 文件如下所示。
#!/bin/sh
mvn clean install
mvn test
当我创建 docker 映像并运行该映像时,它会显示此错误。 试了很多方法还是不行,提示这个错误
没有为此构建指定目标。您必须以 : 或 :[:]: 格式指定有效的生命周期阶段或目标。可用的生命周期阶段有:验证、初始化、生成源、流程源、生成资源、流程资源、编译、流程类、生成测试源、流程测试源、生成测试资源、流程-test-resources、test-compile、process-test-classes、test、prepare-package、package、pre-integration-test、integration-test、post-integration-test、verify、install、deploy、pre-clean、clean ,清理后,站点前,站点,站点后,站点部署。 -> [帮助 1]
【问题讨论】:
-
你确定不执行
mvn没有任何参数,不知何故?
标签: java docker maven dockerfile