dockerfile无法找到添加文件

时间:2018-06-09 07:01:44

标签: docker dockerfile

服务器版本:18.03.1-ce,RHEL 7.2。这是我的dockerfile:

iRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1

它构建没有错误:

FROM openjdk:8-jdk-alpine
ENV http_proxy http://192.168.156.25:3128
ENV https_proxy http://192.168.156.25:3128
RUN  apk update && apk upgrade && apk add netcat-openbsd
RUN mkdir -p /usr/local/licensingservice
ADD @project.build.finalName@.jar /usr/local/licensingservice/
ADD run.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh

但是docker run -it 324d5a83cf84:

 ---> Using cache
 ---> 8fa60876c229
Step 5/9 : RUN mkdir -p /usr/local/licensingservice

 ---> Using cache
 ---> bca46b1256e1
Step 6/9 : ADD licensing-service-0.0.1-SNAPSHOT.jar /usr/local/licensingservice/

 ---> a66979ed3755
Step 7/9 : ADD run.sh ./run.sh

 ---> 95b492565374
Step 8/9 : RUN chmod +x run.sh

 ---> Running in eec3075c30f3
Removing intermediate container eec3075c30f3
 ---> 96a2d7b89b80
Step 9/9 : CMD ./run.sh

 ---> Running in c338e9d33371
Removing intermediate container c338e9d33371
 ---> 324d5a83cf84
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built 324d5a83cf84
Successfully tagged johncarnell/tmx-licensing-service:chapter4

我使用/bin/sh: ./run.sh: not found 进行调试,它可以很好地打印文件。 run.sh:

docker run --rm -it 324d5a83cf84 cat ./run.sh

1 个答案:

答案 0 :(得分:1)

我怀疑您正在使用Windows,并且您使用的是默认的Windows换行符:CR LF。更改为LF中的run.sh,它会像魅力一样发挥作用。

但你问怎么做?在Notepad ++中打开run.sh,然后查看窗口的右下角。单击 Windows(CR LF)并选择 Unix(LF)