DOCKERFILE - PHP WEBSITE

+1 vote

I've pulled the devopsedu/webapp image from docker hub and create an image of out it. 
Now I want to add the PHP website to it and run them in a container. 

I made a dockerfile which is pulling the image and copying PHP code to the machine, but I saw that it's a wrong method, because the dockerfile should contain : 

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

which is not working at all, because I'm getting an error:

ADD failed: stat /var/lib/docker/tmp/docker-builder021352947/website: no such file or directory

My question is: why the dockerfile is looking so weird? From where it pulls the phpcode:https://github.com/edureka-devops/projCert

Oct 9, 2019 in DevOps & Agile by Mateusz
• 160 points

edited Oct 10, 2019 by Kalgi 3,100 views
Do you by any chance have a .dockerignore file? This file might be ignoring the tmp folder.
no i don't have it
Can you show your directory structure?

1 answer to this question.

+1 vote

Here's the Reason why your dockerfile is structured that way.

You have to create a dockerfile and the base image should be devopsedu/webapp. And you have to write dockerfile in such a way that it should run the PHP application. 

The below sample docker file which uses devopssedu/webapp as the base image and then it runs the PHP application. 

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

/var/www/html is the directory where your website files are stored. These files include the codes, images etc used for the website.

The application code is moved or copied inside the container and a docker image is build. An image is created. 

Now when you run this image, the php application will get executed.

answered Oct 10, 2019 by Karan
• 19,610 points
ok now i get this that means the "proj" word in my Dockerfile is the path to the php code etc which is move the /var/www/html folder right ?

Anyway i'm stil getting the same error
Try using relative paths. Recently even I have been facing the same error while using the absolute path.
Hi

Can you help me understand what is relative path here? I am getting the same error
Hi Vennela,

Dockerfile will find the path from its location. This means you have to transfer all your files to that folder where your Dockerfile present.

Related Questions In DevOps & Agile

+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
1,593 views
0 votes
1 answer

High availability (HA) website load balanced across both Azure and AWS?

DNS load balancing is the practice of ...READ MORE

answered Jul 6, 2018 in DevOps & Agile by Kalgi
• 52,350 points
663 views
+1 vote
1 answer

Isolate PHP applications with Docker

That is the idea: you can make ...READ MORE

answered Jul 12, 2018 in DevOps & Agile by Kalgi
• 2,680 points
743 views
0 votes
2 answers

difference between the `COPY` and `ADD` commands in a Dockerfile

Hi, COPY and ADD are both Dockerfile instructions that serve similar purposes. They ...READ MORE

answered Dec 23, 2020 in DevOps & Agile by akhtar
• 38,260 points
5,022 views
0 votes
1 answer

How to give a name to an image in Dockerfile ?

This needs to be done in your ...READ MORE

answered Nov 17, 2018 in DevOps & Agile by Damon Salvatore
• 5,980 points
1,546 views
+2 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,062 views
+1 vote
1 answer

Devops certification project: Dockerfile and PHP website

Try using relative paths. Recently, even I ...READ MORE

answered Nov 14, 2019 in Docker by Eric
3,345 views
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