📁DOCKERFILE
Let's create a Dockerfile and automate some tasks rather than manually typing command. Because we love Automation and we are Lazy :)
To create a DockerFile we will be using vi editor so run the sudo vi Dockerfile
command. Now start typing or copy:
FROM tomcat:latest
COPY ./webapp.war /usr/local/tomcat/webapps
RUN cp -r /usr/local/tomcat/webapps.dist/* /usr/local/tomcat/webapps
save the file by typing esc :wq
Now we have Dockerfile with all the instructions ready. Let's build a image by running :
sudo docker build -t tomcatimage .
Lets run a container using the same command we used previously:
sudo docker run -d -p 8080:8080 --name tomcatcontainer tomcatimage
COMPLETED!! We have successfully built an image and ran a container using Dockerfile and now you can access your code/application on IP:8080/webapps/
BUT! BUT!! what if I say we can automate more!!!! You don't believe me? Check Next section to see the magic where we will provide commands to JENKINS , which will automate creating Docker images and containers for us without SSH-in our EC2 server.
Last updated