Windows 10 WSL2 Docker 构建失败 /bin/sh: /usr/bin/create-user.sh: 未找到

Windows 10 WSL2 Docker build fails with /bin/sh: /usr/bin/create-user.sh: not found

我正在尝试在 Windows 10 WSL2 Docker 上构建映像。 我的 docker 文件是:

FROM i386/openjdk:8-jre-alpine
MAINTAINER Digital Life Studios

EXPOSE 8888/TCP

COPY ["create-user.sh", "startup.sh", "/usr/bin/"]

RUN \
   chmod +x /usr/bin/create-user.sh && \
   chmod +x /usr/bin/startup.sh
RUN \
   /usr/bin/create-user.sh && \
   chown -R java:java /home/java

COPY --chown=java:java "lib" "/home/java/app/BOOT-INF/lib"
COPY --chown=java:java "app" "/home/java/app"

VOLUME /tmp
USER java
CMD ["/usr/bin/startup.sh"]

我 运行 docker 构建的当前文件夹: enter image description here

运行脚本:

docker build --no-cache --tag=<name> .

最后我得到以下信息:

[+] Building 14.6s (8/10)
 => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 527B                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/i386/openjdk:8-jre-alpine                                                                                                                                                                    13.3s
 => CACHED [1/6] FROM docker.io/i386/openjdk:8-jre-alpine@sha256:.....
 => [internal] load build context                                                                                                                                                                                                        0.1s
 => => transferring context: 9.16kB                                                                                                                                                                                                      0.0s
 => [2/6] COPY [create-user.sh, startup.sh, /usr/bin/]                                                                                                                                                                                   0.1s
 => [3/6] RUN    chmod +x /usr/bin/create-user.sh &&    chmod +x /usr/bin/startup.sh                                                                                                                                                     0.5s
 => ERROR [4/6] RUN    /usr/bin/create-user.sh &&    chown -R java:java /home/java                                                                                                                                                       0.6s
------
 > [4/6] RUN    /usr/bin/create-user.sh &&    chown -R java:java /home/java:
#8 0.580 /bin/sh: /usr/bin/create-user.sh: not found
------
executor failed running [/bin/sh -lc /usr/bin/create-user.sh &&    chown -R java:java /home/java]: exit code: 127

请指教

我在 git 拉取后构建图像时遇到了类似的问题。 检查有关 autocrlf

的 git 设置
git config --global core.autocrlf input 

刷新索引

git rm --cached -r .

重写git索引

git reset --hard