Setting up environment for my application

Hi All,

I have following requirement, but do not have clear understanding on approach for it.

Need is to create an image for an application(Web application based on java, running on tomcat, OS is CENTOS 7). There is a .jar file to install this application in unix based machine.

Basically we do following steps when installing our application in unix machine:

  • Install jdk 8
  • Install mysql 5.7
  • Start Mysql
  • Install application using .jar file
  • Start application
  • Access this application from outside of machine (Browser)

Can some one help me out with the approach I should go for.

Regards,
Chandan

This is where docker excels :smiley:.

No, you do not really want to create one image. You want to use some already existing. The underlying OS is not really that important at this point but there are CentOS based images.

Your Docker Stack (https://docs.docker.com/get-started/part5/) consists of these images:

An example docker-compose.yml file would then look like this:

version: "3"
services:
  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: TopSecretPassword
  adminer:
    image: adminer
    restart: always
    ports:
      - 8088:8080
  web:  
    image: tomcat:8-jre8
    ports: 
      - "8080:8080"
    volumes:
      - ./target/DockerExample.war:/usr/local/tomcat/webapps/ROOT.war
      - ./target/DockerExample:/usr/local/tomcat/webapps/ROOT

Walkthrough from the top.
db: is the label and the name of the service running Mysql. It is also the hostname that you should use in your connection string. Here I use the latest gratest. That is the image:
MySQL needs a password or it will generate it. You can pass it as an enrionment variable.
adminer: is a gui for working with databases. I expose that on port 8088.
web: is our webserver. Using the tomcat with the correct JRE installed.
I expose it to the system on port 8080.
volumes: mounts files and directories from my host system into Docker. I used maven to build my DockerExample.war so it is in the target directory of my project.

Put the docker-compose.yml file in the root of the project and run the command

docker-compose up

to get it to run.

That would get you started.