Loma  Baumbach

Loma Baumbach

1600358785

Deploy a Tomcat Application Using Docker-Compose

In this blog, we will learn what is docker-compose and how we can deploy a tomcat application which uses mysql database. We will learn how we can setup a development environment using docker-compose in a single command

Prerequisite:

  1. Docker and Docker-compose installed

INTRODUCTION

  • Docker-compose is a tool which is used to deploy multi-container application.
  • One single yaml file to deploy your application on the server.
  • Best suited for the developers to setup their workstation in a single command without installing any kind of dependencies for the application
  • docker-compose up to start your application
  • docker-compose down to clean up all the docker containers

Let’s take an example here:

We have a project called user registration which uses mysql for storing the data . In terms of microservices, we can say that we have two services as shown below:

  • Web Service
  • Database Service

You can clone this git repo and try the below example

Explanation of docker-compose

  1. **version : **This is the version as per the docker engine you have installed on your machine
  2. **services: **This is the main tag which is used to configure multiple services and under that we have details of all the services

3. web: This is our service name -> using image, ports and volumes

4. **volumes: **To store the database files

Now we will create main docker-compose file which will together launch a tomcat, mysql and phpmyadmin container

Tomcat container — To run your application

**Database container **— To store the data

PhpMyAdmin — Access the database through GUI

So we will have three services

  1. db — we are using local path to store the data so that when you run docker-compose down all your data will retain. If you use the volume then all data will get lost if you run the docker-compose down

Also, we are importing sql file so that our database is ready with the sample data. It is good so that each developer will always have the base or the actual data to run their application on the local machine

2. phpmyadmin — which is used to access the database through GUI and it depends on service db

3. web — which is used to access your web application and it also depends on service db

version: '3.3'
services:
   db:
     image: mysql:5.7
     volumes:
       - /opt/test:/var/lib/mysql
       - ./mysql-dump:/docker-entrypoint-initdb.d
     environment:
       MYSQL_ROOT_PASSWORD: root
       MYSQL_DATABASE: testdb1
       MYSQL_USER: testuser
       MYSQL_PASSWORD: root
     ports:
       - 3306:3306
phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    ports:
      - '8081:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: root
web:
    depends_on:
      - db
    image: tomcat
    volumes:
      - ./target/LoginWebApp-1.war:/usr/local/tomcat/webapps/LoginWebApp-1.war
    ports:
      - '8082:8080'
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: testdb1
      MYSQL_USER: testuser
      MYSQL_PASSWORD: root

#docker-compose #docker-image #docker

What is GEEK

Buddha Community

Deploy a Tomcat Application Using Docker-Compose
Loma  Baumbach

Loma Baumbach

1600358785

Deploy a Tomcat Application Using Docker-Compose

In this blog, we will learn what is docker-compose and how we can deploy a tomcat application which uses mysql database. We will learn how we can setup a development environment using docker-compose in a single command

Prerequisite:

  1. Docker and Docker-compose installed

INTRODUCTION

  • Docker-compose is a tool which is used to deploy multi-container application.
  • One single yaml file to deploy your application on the server.
  • Best suited for the developers to setup their workstation in a single command without installing any kind of dependencies for the application
  • docker-compose up to start your application
  • docker-compose down to clean up all the docker containers

Let’s take an example here:

We have a project called user registration which uses mysql for storing the data . In terms of microservices, we can say that we have two services as shown below:

  • Web Service
  • Database Service

You can clone this git repo and try the below example

Explanation of docker-compose

  1. **version : **This is the version as per the docker engine you have installed on your machine
  2. **services: **This is the main tag which is used to configure multiple services and under that we have details of all the services

3. web: This is our service name -> using image, ports and volumes

4. **volumes: **To store the database files

Now we will create main docker-compose file which will together launch a tomcat, mysql and phpmyadmin container

Tomcat container — To run your application

**Database container **— To store the data

PhpMyAdmin — Access the database through GUI

So we will have three services

  1. db — we are using local path to store the data so that when you run docker-compose down all your data will retain. If you use the volume then all data will get lost if you run the docker-compose down

Also, we are importing sql file so that our database is ready with the sample data. It is good so that each developer will always have the base or the actual data to run their application on the local machine

2. phpmyadmin — which is used to access the database through GUI and it depends on service db

3. web — which is used to access your web application and it also depends on service db

version: '3.3'
services:
   db:
     image: mysql:5.7
     volumes:
       - /opt/test:/var/lib/mysql
       - ./mysql-dump:/docker-entrypoint-initdb.d
     environment:
       MYSQL_ROOT_PASSWORD: root
       MYSQL_DATABASE: testdb1
       MYSQL_USER: testuser
       MYSQL_PASSWORD: root
     ports:
       - 3306:3306
phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    ports:
      - '8081:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: root
web:
    depends_on:
      - db
    image: tomcat
    volumes:
      - ./target/LoginWebApp-1.war:/usr/local/tomcat/webapps/LoginWebApp-1.war
    ports:
      - '8082:8080'
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: testdb1
      MYSQL_USER: testuser
      MYSQL_PASSWORD: root

#docker-compose #docker-image #docker

August  Murray

August Murray

1615139520

A beginner’s guide to deploying a Docker application to production using Docker Compose

In this lesson, we are going to learn how Docker Compose works and how it can be used to deploy & manage multiple containers in the production environment.

In the previous lessons, we discussed the basics of Docker. We learned the anatomy of Docker containers, the structure of a Dockerfile, how to create images, how to manage containers, etc. This is just the basic information we need to know in order to operate Docker.

If our application is as simple as an HTTP server, we can run it inside a single Docker container. You can create a custom Docker image, copy the application code to the image, and run a container from it. You can mount a volume for persistent data storage and bind a port on the host to the port on the container to make your service public. That’s it. After that, we would need to manually monitor the container in case it goes down.

However, in reality, our application is made up of different services. For example, we might have a frontend service that serves the web application, a backend service that provides a REST API to the frontend, and a database service that stores the user data.

These services can be dependent on each other. For example, the frontend service depends on the backend service and the backend service depends on the database service. Unless we have all the services up and running, our application won’t function properly. They might need to be started in the right order for things to go well.

Doing this manually is cumbersome. Not everyone on your team will have the context of the entire application. It’s a big metadata to carry and you can’t afford to mess things up. You need some sort of orchestration tool to automatically manage your services. You want this tool to configure your services, manage startup and shutdown as well as handle failures. This is where Docker Compose comes in.

#docker-compose #devops #continuous-integration #docker #software-development

Iliana  Welch

Iliana Welch

1595249460

Docker Explained: Docker Architecture | Docker Registries

Following the second video about Docker basics, in this video, I explain Docker architecture and explain the different building blocks of the docker engine; docker client, API, Docker Daemon. I also explain what a docker registry is and I finish the video with a demo explaining and illustrating how to use Docker hub

In this video lesson you will learn:

  • What is Docker Host
  • What is Docker Engine
  • Learn about Docker Architecture
  • Learn about Docker client and Docker Daemon
  • Docker Hub and Registries
  • Simple demo to understand using images from registries

#docker #docker hub #docker host #docker engine #docker architecture #api

Containerized Applications and Deploy Simple Application on Docker

If you are a software engineer, you must know where your application is deployed. A few years back, web applications were deployed on dedicated physical servers. The evolution of application deployment can be considered as three generations. Let’s explore it for your knowledge.

Generation 1 — Dedicated Physical Servers

Earlier days, the application was deployed in a dedicated physical server. You may think that nowadays also deployed on physical servers. But it was a different story. For example, if your application needs to have different servers like the application server, database server, mail server, and web server, you must have four different hardware boxes (physical servers) to deploy this application.

There are many disadvantages of these servers.

  • Space for servers (Server room)
  • Maintenance cost (air-conditioned room, security, service)
  • Separate network
  • Operation systems
  • Resources waste (servers are not used 100% of processing power/ memory)

#containers #docker #containerized applications #deploy simple application

Deploy and Run Spring boot with MySQL Application in Docker and Docker Compose

In this video you will learn how to Dockerize spring boot with MySQL application and Dockerize a Spring Boot with MySQL using docker-compose in Ubuntu machine.

Git Hub Link: https://github.com/shameed1910/springboot-mysql-docker.git
Previous video link: https://youtu.be/EZolJ4lNiYc

#mysql #docker #docker compose #spring boot