⚙️
DevOps Mastery on AWS
  • 🤓Continuous Integration & Continuous Deployment on AWS Cloud
  • 🤖Jenkins
    • 🛠️Build Jenkins First Job
    • 🦸Launch 2nd EC2 instance
  • 🐳Docker
    • 📁DOCKERFILE
  • 🛺Ansible
    • 📖Ansible Playbook
  • 🏃‍♂️Continuos Integration with GitHub and Jenkins
  • 👷Project Structure & summary.
  • Basics
Powered by GitBook
On this page
  1. Docker

DOCKERFILE

Let's create a Dockerfile and automate some tasks rather than manually typing command. Because we love Automation and we are Lazy :)

PreviousDockerNextAnsible

Last updated 3 years ago

To create a 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.

🐳
📁
DockerFile