Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Docker build is failing in pipeline

Birajendu Sahu February 5, 2018

I have simple docker file as below which works fine if i build locally.

FROM openjdk:8-jdk-alpine
MAINTAINER My team "contact@mycompany.io"
RUN mkdir /app
WORKDIR /app
COPY myapp-0.0.1.jar /app
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "myapi-0.0.1.jar"]
ENV JAVA_OPTS -server
EXPOSE 8080
VOLUME ["/tmp"]

When I try to run same from bitbucket pipeline it shows following error

 

Building image using context '/opt/atlassian/pipelines/agent/build'.Using tag 'io.mycompany.api/api:0.0.1' for image.Step 1/7 : FROM openjdk:8-jdk-alpine---> 224765a6bdbeStep 2/7 : MAINTAINER My team "contact@mycompany.io"---> Running in b2fd28aa71f5---> 541c8f463238Removing intermediate container b2fd28aa71f5Step 3/7 : ADD myapi-0.0.1.jar app.jar:buildDocker FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':buildDocker'.> Could not build image: lstat myapi-0.0.1.jar: no such file or directory

 

Where as myapi-0.0.1.jar is there in root dir

1 answer

1 vote
SebC
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 6, 2018

Hey @Birajendu Sahu,

the key of the error message is

lstat myapi-0.0.1.jar: no such file or directory

in your Dockerfile you have the instruction

COPY myapp-0.0.1.jar /app

 Which copies myapp-0.0.1.jar from the root of your docker context.

When you run docker build, ensure your jar file exists and is readable by the docker client.

 

thanks,

Seb

Birajendu Sahu February 6, 2018

Hi @SebC,

 

Thanks for your response. I an not sure how to check files presence in bitbucket pipeline build. The same dockerfile works fine in local mac system.

 

regards,

Birajendu 

SebC
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 6, 2018

I would add commands into the script section of your pipeline. If you add ls -al ahead of docker build, you see all the files in your working directory.

Birajendu Sahu February 7, 2018

Will try, Thanks.

Birajendu Sahu February 8, 2018

Thanks @SebC,

 

I was able to resolve the issue with help of ls -al.

 

Thanks,

Birajdndu

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events