DOCKERFILE
DevOps Instructor-led Training
Contact us:
TOACCELERATEYOURCAREERGROWTH
For questions and more details:
+91 98712 72900
https://www.thecloudtrain.com
[email protected]
+91 98712 72900
CREATING A DOCKERFILE
Step 1: First, create a folder docker, in the home
directory
mkdir docker
cd docker
Step 2: Enter into this directory, and create a file
called 'Dockerfile', with the same contents as the
Sample Dockerfile. Add the following content in the
Dockerfile.
sudo vim Dockerfile
FROM ubuntu
ENV TZ=Asia/Kolkata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >
/etc/timezone
RUN apt-get update
RUN apt-get -y install apache2
ADD . /var/www/html
ENTRYPOINT apachectl -D FOREGROUND
ENV name Devops Tutorial
sudo vim index.html
Step 3: Create one more file called, index.html with
the following contents can verify the push on
DockerHub.
<html>
<title> Sample Website </title>
<body>
Hello World
</body>
</html>
docker build <directory-of-dockerfile> -t <name of image>
Step 5: Finally, run this built image, using the
following command:
docker run –it –p 81:80 –d <name of image>
Step 6: Now navigate to the server IP address on
port 81
Step 7: Finally, login into the container, and check
the variable $name, it will have the same value, as
given in the Dockerfile.