# DOCKERFILE

To create a [**DockerFile** ](https://codefresh.io/docker-tutorial/build-docker-image-dockerfiles/)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 :&#x20;

`sudo docker build -t tomcatimage .`

![](https://2593464885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3DMI85ymmo2BqduKTK9p%2Fuploads%2FHVbXkFojYo4kPFQ9vuKB%2Fimage.png?alt=media\&token=5bdabaf3-1683-41b5-b459-ddfe8d5edd62)

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.
