将在 unix 中测试的 dockerfile 转换为 windows,运行 命令由于权限被拒绝而失败

Convert dockerfile tested in unix to windows, RUN command failing due to Permission denied

我有一个如下所示的 Dockerfile,经过测试可在 Unix 系统上运行。我的客户试图在 windows 上使用相同的方法,但在 RUN ./gradlew clean deployNodes 步骤上出现 Permission denied 错误。

如何调整我的 Dockerfile 使其在 Windows 系统上也能正常工作?

# Get java8
FROM openjdk:8-jre-slim
# Get gradle
FROM gradle:4.7.0-jdk8-alpine AS build
# Start as root to update the alpine image to install bash
USER root
# Add bash
RUN apk update && apk add bash
# Move the code, as owner
COPY --chown=gradle:gradle . /home/gradle/src
# Assign a working directory 
WORKDIR /home/gradle/src
# Run clean build
RUN ./gradlew clean deployNodes
# Expose ports for the services
EXPOSE 8080 5005 5006 5007 5008 5009 10001 10070
# Run the application
ENTRYPOINT ["build/nodes/runnodes"]

编辑:

错误在:

/bin/sh: ./gradlew: Permission denied
The command '/bin/sh -C ./gradlew clean deploynodes' returned a non-zero code: 126

在这个线程之后,我将 gradlew 设为可执行文件: gradlew: Permission Denied

尝试添加:

WORKDIR /home/gradle/src
RUN apt-get update && apt-get install -y dos2unix
RUN dos2unix gradlew
RUN chmod +x gradlew
RUN ./gradlew clean deployNodes