我在Windows操作系统上运行。我尝试使用Git bash在minikube上构建docker镜像,并使用docker终端在docker上构建。我收到错误 RUN [" ./ gradlew"," clean"," build"," - debug"] 即可。在终端上运行相同的命令 ./ gradlew clean build --debug 时,它可以工作。
Docker文件:Docker-build
FROM openjdk:8u131-jdk-alpine
COPY . /app
WORKDIR /app
RUN ["./gradlew", "clean", "build", "--debug"]
终端输出:
Local User@PC MINGW64 /E/projects/authentication (master)
$ docker build -t my-image -f Dockerfile-build .
Sending build context to Docker daemon 51.7MB
Step 1/4 : FROM openjdk:8u131-jdk-alpine
---> 478bf389b75b
Step 2/4 : COPY . /app
---> 818b5bb8a22d
Removing intermediate container 02b237aa04c0
Step 3/4 : WORKDIR /app
---> e238b49f5174
Removing intermediate container cd052cd7975a
Step 4/4 : RUN ./gradlew clean build --debug
---> Running in c47b21d9a0bc
': No such file or directory
The command './gradlew clean build --debug' returned a non-zero code: 127
注意:gradlew位于我当前的目录/ E / projects / authentication
答案 0 :(得分:1)
将gradlew text eol=lf
添加到.gitattributes为我工作,因为我在Windows上从Git Bash运行。这是由于跨平台线端缺失。
答案 1 :(得分:0)
尝试更改
RUN ["./gradlew", "clean", "build", "--debug"]
到
RUN gradlew clean build --debug
对于RUN
命令,无需添加[,]
。主要用于CMD, ENTRYPOINT
解决此问题的一般解决方案是进入系统进行调试
对于这种情况。
Removing intermediate container 02b237aa04c0
Step 3/4 : WORKDIR /app
---> e238b49f5174 <== useful image !!
Removing intermediate container cd052cd7975a
然后你可以运行图像来检查内部
docker run -it e238b49f5174 bash
# ls
# gradlew clean build --debug
大多数情况下,你会弄清楚它是什么。如果您可以将这些代码(或部分代码)放入github
,那将会很好