yuxh
yuxh

Reputation: 954

dockerfile Add file can not be found

Server Version: 18.03.1-ce ,RHEL 7.2 .Here is my dockerfile:

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 @[email protected] /usr/local/licensingservice/
ADD run.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh

it build without error:

 ---> 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

but docker run -it 324d5a83cf84:

/bin/sh: ./run.sh: not found

I debug using docker run --rm -it 324d5a83cf84 cat ./run.sh,it print the file well. run.sh:

#!/bin/sh
echo "hello1"

Upvotes: 0

Views: 255

Answers (1)

Derlin
Derlin

Reputation: 9891

I suspect you are working on Windows and you are using the default Windows newline: CR LF. Change to LF in your run.sh and it will work like a charm.

But how to do that you ask? Open run.sh in Notepad++ and look at the bottom right of the window. Click on Windows (CR LF) and select Unix (LF).

Upvotes: 1

Related Questions