Friday, April 08, 2016

Tomcat 8 Docker install on Ubuntu 14.04

Below are the steps for installing Tomcat 8 within a Docker container on Ubuntu 14 , in my case on Amazon Ec2.

Docker Install

You need to first follow the instructions for setting up docker :
https://docs.docker.com/engine/installation/linux/ubuntulinux/


Tomcat Install

- identify your Ubuntu instance in my case I wanted to run it with JDK 8 so first navigate to Docker Hub :

https://hub.docker.com/_/tomcat/

- Then choose the correct docker image version :


So this is going to be version 8.0.33-jre8

- Login to your ubuntu
- Execute the following command

sudo docker run -it --rm -p 8080:8080 tomcat:8.0.33-jre8

This will download the Tomcat 8 with JDK 8 image and start it on port 8080 .

You will be able to access your tomcat instance http://public_id_address:8080

Docker Commands

- To check which docker containers are running execute the command

sudo docker ps

You should see something like this:

CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS                    NAMES
40586996cebe        tomcat:8.0.33-jre8   "catalina.sh run"   31 minutes ago      Up 31 minutes       0.0.0.0:8080->8080/tcp   jolly_almeida


- To stop the docker container choose the docker container id , which you find when doing docker ps :

sudo docker stop 40586996cebe

- To restart the tomcat conatiner re-execute:

sudo docker run -it --rm -p 8080:8080 tomcat:8.0.33-jre8



No comments: