0% found this document useful (0 votes)
3 views

Dockerize Spring Boot With MySQL

The document provides a step-by-step guide for dockerizing a Spring Boot application with a MySQL database. It includes commands for pulling the MySQL image, cloning the Spring Boot project, building the application, creating a Docker network, and running both the MySQL and Spring Boot containers. The final instructions detail how to access the application via a public URL.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Dockerize Spring Boot With MySQL

The document provides a step-by-step guide for dockerizing a Spring Boot application with a MySQL database. It includes commands for pulling the MySQL image, cloning the Spring Boot project, building the application, creating a Docker network, and running both the MySQL and Spring Boot containers. The final instructions detail how to access the application via a public URL.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

4/29/23, 3:23 PM https://ashokitech.com/uploads/notes/33447707_1664730157.

txt

===================================
Dockerizing Spring Boot + MySQL
===================================

# Pull MySQL DB image


$ docker pull mysql:5.7

# Download required softwares


$ sudo yum install git -y
$ sudo yum install maven -y

# Clone Spring Boot Project From Github


$ git clone https://github.com/ashokitschool/spring-boot-mysql-docker-compose.git

# Get into project directory


$ cd <project-dir>

# Package application
$ mvn clean package

# Create Application image


$ docker build -t sb-app .

# Check docker images


$ docker images

# Create Docker Network


$ docker network create springmysql-net

# See networks available


$ docker network ls

# Run mysqldb as a docker container


$ docker run --name mysqldb --network springmysql-net -e MYSQL_ROOT_PASSWORD=root -e
MYSQL_DATABASE=sbms -d mysql:5.7

# check logs of container


$ docker logs -f <container_name>

If needed we can check if the database has been created correctly.

We can do the following commands.

$ docker exec -it <container_id> bash


$ mysql -u <username> -p
$ show databases;

# Run springboot application as a container


$ docker run --network springmysql-net --name sbapp-container -p 8080:8080 -d sb-app

# check the containers which are running


$ docker ps

# check logs of application container


$ docker logs -f <container_id>

# We can access our application now

URL : http://ec2-vm-public-ip:8080/

https://ashokitech.com/uploads/notes/33447707_1664730157.txt 1/2
4/29/23, 3:23 PM https://ashokitech.com/uploads/notes/33447707_1664730157.txt

https://ashokitech.com/uploads/notes/33447707_1664730157.txt 2/2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy