Build Docker image for PHP Web application - ADD failed

+1 vote
I have created a dockerfile with the base image devopsedu/webapp for PHP web application.

FROM devopsedu/webapp
ADD proj /var/www/html
RUN rm /var/www/html/index.html
CMD apachectl -D FOREGROUND

When I tried to build the docker image using dockerfile, it failed on step 2 indicated that "no such file or directory" error message.

edureka@server:$ docker build -t devopsedu/webapp:dockerfile .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM devopsedu/webapp
 ---> 0ef91240e173
Step 2/4 : ADD proj /var/www/html
ADD failed: stat /var/lib/docker/tmp/docker-builder032612005/proj: no such file or directory
Jul 13, 2019 in Docker by limcw
• 270 points
2,633 views
Paths in your Dockerfile are not absolute paths on your filesystem, but relative to the build-context. Check if that is within the build context.

1 answer to this question.

+2 votes
Best answer
Thank you Sirajul

Yes, I have changed it to the absolute paths on my filesystem and it is working now.

FROM devopsedu/webapp
ADD website /var/www/html
RUN rm /var/www/html/index.html
CMD apachectl -D FOREGROUND
answered Jul 15, 2019 by limcw
• 270 points

selected Jul 16, 2019 by Vardhan
Glad to help! @limcw :)
How to Create absolute path for website
How to Create absolute path
Hi can you just give an example of the error with a correction with regards to devopsedu/webapp  because still m getting error

Hey @Animesh, this was the error

edureka@server:$ docker build -t devopsedu/webapp:dockerfile .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM devopsedu/webapp
 ---> 0ef91240e173
Step 2/4 : ADD proj /var/www/html
ADD failed: stat /var/lib/docker/tmp/docker-builder032612005/proj: no such file or directory

I changed the path to an absolute path. The absolute path of your resources refers to an absolute path within the build context, not an absolute path on the host. 

So all the resources must be copied into the directory where you run the docker build and then provide the path of those resources within your Dockerfiles before building the image. (This refers to the location where you run your Dockerfile).
 

This resolved the error for me.

Related Questions In Docker

0 votes
1 answer

build context for docker image very large

The Docker client sends the entire "build ...READ MORE

answered Aug 1, 2018 in Docker by Kalgi
• 52,350 points
14,656 views
0 votes
2 answers

How do I force Docker for a clean build of an image ?

You could try this inorder to clean ...READ MORE

answered Aug 6, 2019 in Docker by Sirajul
• 59,230 points
10,700 views
0 votes
1 answer

How do I delete the build cache for a docker image?

You could try this inorder to clean ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,230 points
12,635 views
0 votes
1 answer

build an J2EE application with docker

I would suggest you to use volume ...READ MORE

answered May 1, 2018 in Docker by shubham
• 7,340 points
914 views
0 votes
2 answers

How can I inspect the file system of a failed `docker build

Failed command is a build that has ...READ MORE

answered Aug 6, 2018 in Docker by Nilesh
• 7,060 points
3,135 views
0 votes
1 answer

Docker Swarm- Build image only when stack deployed from manager node

Use docker build to build the image. ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 7,060 points
1,293 views
0 votes
1 answer

How to run an image with volume on docker for windows?

Try : declaring the volume of container mounting the ...READ MORE

answered Sep 20, 2018 in Docker by Tyrion anex
• 8,700 points
883 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP