How to Run/Deploy Spring Boot & MySQL in Docker? | Tech Primers
Тәжірибелік нұсқаулар және стиль
This video covers how to create a Docker image for a Spring Boot App and how to run Spring boot & MySQL in a Docker container
🔗Code in GitHub: github.com/TechPrimers/docker...
📌 Related Playlist
================
🔗Spring Boot Primer - • Spring Boot Primer
🔗Spring Cloud Primer - • Spring Cloud Primer
🔗Spring Microservices Primer - • Spring Microservices P...
🔗Spring JPA Primer - • Spring JPA Primer
🔗Java 8 Streams - • Java 8 Streams
🔗Spring Security Primer - • Spring Security Primer
🔗Containers Primer - • Containers Primer
🔗Kubernetes Primer - • Kubernetes Primer
🔗AWS Primer - • AWS Primer
💥Join TechPrimers Slack Community: bit.ly/JoinTechPrimers
💥Telegram: t.me/TechPrimers
💥TechPrimer HindSight (Blog): / techprimers
💥Website: techprimers.com
💥Slack Community: techprimers.slack.com
💥Twitter: / techprimers
💥Facebook: TechPrimers
💥GitHub: github.com/TechPrimers or techprimers.github.io/
🎬Video Editing: iMovie
🎼Background Music:
fredji
Joakin Karud
---------------------------------------------------------------
🔥 Disclaimer/Policy:
The content/views/opinions posted here are solely mine and the code samples created by me are open sourced.
You are free to use the code samples in Github after forking and you can modify it for your own use.
All the videos posted here are copyrighted. You cannot re-distribute videos on this channel in other channels or platforms.
#Docker #SpringBoot #TechPrimers
Пікірлер: 211
I can't believe how clear, concise and relevant this tutorial was, thank you!
Wow, impressed by how calmly you explained the entire container setup! This video helped a lot.
Its just amazing the way you have explained a simple workflow. Thank you very much for your effort.
you are the best "Techprimers" . I never missed any of your videos . keep up your great work bro
You made a lot of thing to be clear to me. Thank you!
This is a very helpful video , thank you!
Thank you ! You made a lot of thing to be easy and clear to me!
I like this music piece in the beginning :D
Excellent tutorial. You explain the docker CLI commands really well, makes it easy to understand. Thanks!
@TechPrimers
3 жыл бұрын
Glad it was helpful!
very helpful tutorial keep doing it.
Thank you for this tutorial I learn a lot from this.
Its clear and explained well. Thank you.
Very helpful tutorial. Thank you very much.
You made my day.. Really am looking this type of video..keep do more video..
clear, practical, best!
Such a awesome tutorial. WOW.
So clean. Thanks.
Big thanks to Techprimers....i really enjoyed practical implementation of this.
very nice video! thanks!
Perfect tutorial
I like the way you teach. We can see the mistakes and learn from them
Beautiful, thank you.
Thank you Tech Primers. 👍
@TechPrimers
6 жыл бұрын
+Vishwas Raghav my pleasure Vishwas
Thanks. Really helpful.
Your videos are awesome. And can you please post a tutorial on autocruise CI CD pipeline with Docker and Jenkins. Thanks!!
Wow you are amazing. Really helps me a lot. thank you!
Thanks. You cleared lot of my doubts
Nice start thanks so much
how to integrate the one dependent microservice into another microservice
what if i want to use docker while development is going on so that we can configure it once and any number of developers can be on boarded on same project without hassle of configuring project on their machine. this seems to be for the time when dev. is done and you only need to deploy for client.
Just in time 🤘🏻
@TechPrimers
6 жыл бұрын
+Avinash Baghel cheers
thank you so much brother ..keep it up ..
Perfect 👌.. Please update this amazing tutorial to 2021
Thanks man
So much well described, Just loved it
@TechPrimers
3 жыл бұрын
Glad you liked it!
@MahadiHasan-qb9zw
3 жыл бұрын
@@TechPrimers I have tried same as yours but a error said Communication link failure can you help me why this is happening ?
thank you sir!
Very nice explanation 👍.
A very helpful tutorial. But I prefer to use docker-compose instead link command. Cheers
@tamelo
5 жыл бұрын
Do you know a tutorial to make it work? I need to run two Spring app that use the same mysql db. They work fine if I start them separately, but I can´t make them work with compose.
Great tutorial. I am learning lot of concepts which i am unable to get on other sites. I have one clarification. My MySQL database contains lot of tables and relationships. Can we use MySQL query browser(or other UI) to create database and tables and use this database in the docker image.
Hi, I got the following exception: java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'. Any help please
15:30 do we need not to up openjdk container as a seperate container same as MySQL server container ? If not required, from which container it will use java ?
I am using the docker-compose for the same purpose but when I provide the jdbc connection properties in .properties file. maven build fails for me. Any idea how to resolve this ?
how are you running two container i mean one container for mysql and one for spring boot can you explain please i am not able to run my application while connecting with mysql db
Hello, I´m having trouble making it work with docker-compose. I have two spring-boot apps that access the same mysql database. They all work perfectly without docker, and also work if each app is docked. But not work with compose.
Hi, I have two questions. 1. As you not mounted any Data base file path to docker volume, let's say you created a user record then stop the container and again start it. So what ever the record you saved, it will be wiped out if we do simply a get request to check any user is there or not. let me know if I am wrong or right. 2. In the example you have run only one container of my sql. But in production (in AWS or any cloud) it will be multiple containers (e.g., kubernetes worlds multiple pods of mysql will be running in different hosts and form a service) . I understood you will specify the service name of my sql in application.properties file but when you run the spring boot application as a container what value you will provide --link ??
Thanks for the awesome videos, just wondering how to connect to host computer mysql database?
@TechPrimers
5 жыл бұрын
instead of the service name, you the hostname in the url
how can u communicate from ur local machine with the mysql container without publishing the port ? Thank you for the video.
How about using a docker-compose file having both the MySQL and sample project. This way there is no need to wait for the MySQL container to start.
Hello, why does we see multiple delete messages for an individual image rm command
when i am using this same method.... i m getting a unknown host exception
Is it better to deploy mysql in its own container? or bundle mysql + jdk app together? What are the pros and cons of each approach..
Crisp and to the point explanation! Sam's salary was too low though. Yupp :-)
Hi Can, you please make a video on Run/Deploy Spring Boot & Oracle in Docker
Can you do the videos on docker-compose as well?
감사합니다.. ㅠㅠ Thank you
If u have created new container from MySQL docker image , how does the user table came into it automatically..? Thanks in advance for the answer
hi when i changed localhost to my SQL container service name in application properties file , my project was giving build error on mmaven install, can you please help me with this, is anything else need to be configured??
Nice video..can you pls guide how to call microserices running in differnent containers
Thanks for your video bro. I am new to the docker. Now I know how to create and deploy simple application in docker container. I have one query, I am seeing people are specifying openjdk as a parent image. It's adding 600 to 1000 MB to my local image depending on the version of jdk. Why we need to add jdk as a parent image. Can we skip the jdk and add jvm as a parent ?. And in real time people are using yml file to define the external dependencies. Can you explain what is the deference between running mysql as a standalone image and other way
Well back in 2017 you had to use the --link argument to make two containers communicate.Nowadays --link is deprecated but you can still use it but in the future it will be completely removed, now you can just use networking capabilities of docker and they will communicate without problem inside a docker network
Thank u so much !!
@TechPrimers
2 жыл бұрын
You're welcome!
Good explanation. Can we get video with Docker compose explained
Hi, Neatly explained. Small help.Could you please do a video on dockerizing spring boot app +mongodb? Basically, I want to create a MongoDB container and another one for the app and create a network between them and run. I have created the app with spring boot and mongodb but some how I am not able to run it on docker
@TechPrimers
6 жыл бұрын
sure. will do
why is it you are not getting mysql image from but only open-jdk. If I have a new docker setup I need to get both openjdk and mysql. can we get that? am I missing anything?
I would suggest to create playlist for similar videos which are in parts like create a playlist for Docker and its implementation and add all three videos to it. It will give user a direct access to all part of videos. Otherwise it is difficult to identify the sequence. Thanks.
Thank you
I'm following the tutorial on MacBook Pro but I get below error due to 'unknown host exception' when trying to connect to mysql. Error is as below HikariPool-1 - Exception during pool initialization. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure Can anyone help with this issue?
Docker-compose explanation would be Nice for building linking and running multiple containers
@TechPrimers
6 жыл бұрын
+Antonio Shizko sure Antonio. Will do
For windows users, whom it's not working please use the command: docker-machine ip and then instead of localhost use the machine ip address. Thanks for the amazing explaination.
@safeerkhan2837
4 жыл бұрын
hi, Could you please elaborate. i not able to connect on windows, how to get docker-machine IP?
1. Can I run the spring boot from localhost to connect my-sql db available in the container? 2. Or do we really to have the App and DB in the container and link both the container? Since I'm unable to to connect from local system
@feiomaskatista
4 жыл бұрын
1. Yes you can!
When I do this, I get an error which says "Caused by: java.sql.SQLSyntaxErrorException: Unknown database 'test'". I have checked and made sure that the name of the database is consistent. Is it necessary to make a docker-compose file? Please let me know.
Very useful, How to stop rebuild process again and again(and directly reflect changes) while in development mode ?
@TechPrimers
5 жыл бұрын
you can automate it via script, apart from that we cannot do anything since re-creation of image is necessary
Whether u r suggesting to have single database shared among all microservices or database and schema per service?
Bro how can we run docker compose with mysql
couple questions, because this didn't go as smooth with me as it did with you. 1. changing localhost to mysql-standalone made building impossible for me, but worked when I returned it back to localhost, what can be the reason for this ? (using mysql:latest as an image) 2. when I build with localhost, it has trouble seeing schemas (containers don't have the same schema configuration I guess), how do I fix this ? (my solution: hibernate.dll-auto=update, but it's still iffy) 3. even if I build with localhost (instead of mysql-standalone) and make an image file, it doesn't run on a second container because of ConnectionRefused exception, when I try running with cmd directly through the jar it works fine, as soon as I try to move it to the container It doesn't like the sql container is my guess, how can I solve all these problems ? >.
@jasper5016
2 жыл бұрын
I faced same issues.
@levanapakidze1606
2 жыл бұрын
@@jasper5016 couldn't figure it out, nor find any source about the subject, so gave up, can't help u with anything, sry
@akshaynilkanth9671
Жыл бұрын
HI Levan, i faced same issues few thigs that i tried and worked for me 1.After changing application. Properties file in your app comment the following from src/test/java maine file ------> @Test void contextLoads(){} 2.After creating the image while running it you should link the mysql container too....it is mentioned in the vdo . . .these things should work for you
Communication link failure and operation create user failed for root @ are the errors Im getting for logs command😔
I GET THIS WHILE I DO docker build. Step 1/4 : FROM openjdk:8 8: Pulling from library/openjdk no matching manifest for windows/amd64 in the manifest list entries
If my db mysql is installed in another machine and i m accessing through port and host name in that case should i install mysql images?
@TechPrimers
5 жыл бұрын
Nope. You need to install only the runtime requirements. You will anyway use MySQL java client which will come in ur jar already
my container goes to exited state imediately after creating...why?
Hi, I’m trying to connect to a docker container during development. I’m using eclipse in Macintosh and when I run the spring boot application runner, I’m getting communications link failure error. Can you please suggest what am I missing?
@RanjithKumar-qj9mn
3 жыл бұрын
Check SQL docker is running or it may be because of test files ignore it by using the command -> mvnw clean install -Dmaven.test.skip=true good luck
Avery helpful , Can you show us how deploy that in Droplet in digitalocean pleaaaaaase
@TechPrimers
6 жыл бұрын
Hi Kais, is the DigitalOcean providing any free service? I can give it a try
run a docker mysql container.The app spring.datasource.url = jdbc:mysql:mysql-containername:3306 will not recognize the container. mvn package failled because of Caused by: java.net.UnknownHostException: mysql-containername? how can you mvn install and create a jar?
where to see our data and how to connect MySQL workbench
Hi When i change localhost to mysql-standalone within the aplication.properties file I couldn't generate my jar cauz of this error : The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
@abderrahimrafia5583
4 жыл бұрын
Just skip tests and it ll be fixed
@rohithakash8093
4 жыл бұрын
@@abderrahimrafia5583 how do you skip the test
@paragkadam2169
4 жыл бұрын
@@rohithakash8093 ./gradlew build --exclude-task test
@julioluque302
4 жыл бұрын
thanks. my project compile now!!!!
@julioluque302
4 жыл бұрын
@@rohithakash8093 mvn install -Dmaven.test.skip=true
I have error while running localhost:8080 as Failed to load remote configuration. Can anyone help me to figure out this.I tried it too many times but same error...
Great useful video. One question can we access the mysql container to see the databases
@TechPrimers
5 жыл бұрын
Yes you can
Hi sir nice explained.but some doubts please clarify. 1)when ever spring boot application build after created jar or war.this jar or war file again convert into images and deployed into docker container. 2)why not create maven image. 3)what is difference b/w docker container and docker Engine.
@TechPrimers
5 жыл бұрын
1) Yes. Because docker needs its runtime+artifact - so docker image = JRE+JAR or Tomcat+WAR 2) Maven is a build tool, we need runtime middlewares (tomcat/JRE) for our artifacts to run. 3) Docker Container - its like a VM where our processes will be installed/running. Docker Engine - Creates the necessary setup for creating a Docker Container in your laptop/linux machine
could you please do a video on aws and spring boot
@TechPrimers
6 жыл бұрын
Hi Gurmeet, I have done it already. Take a look at here: kzread.info/dash/bejne/aIam09uthJOTeZs.html
If I have a RDS and spring boot is running inside an EC2 machine then how will I give Mysql credentials using docker run.
@TechPrimers
3 жыл бұрын
You can pass via env file or using vault. For env file, there is a -env parameter. Check docker command help
I'm gettong this error "The driver has not received any packets from the server."
Using 'mysql-standalone' as host address inside the application.properties in spring-boot project caused compilation errors during 'mvn clean install' for JAR creation spring.datasource.url=jdbc:mysql://mysql-standalone:3306/test1 Log says 'unknown host exception' Further, I identified the IP address of the running mysql container ('mysql-standalone') using 'docker inspect ' and then used it inside the application.properties to make it working I am not sure but I can't rely on IP Address since this could change next time. Below is the working settings- spring.datasource.url=jdbc:mysql://172.17.0.2:3306/test1
@safeerkhan2837
4 жыл бұрын
Hey, did you find solution to this?
Do we need always to delete image and to build a new one to see the code changes ?? does someone have any other Idea ?
@TechPrimers
5 жыл бұрын
Yes you have to rebuild always
How can i run the second container instance of the spring boot application
@TechPrimers
5 жыл бұрын
you can trigger same docker run with different ports
can u explain properties vs yaml
@TechPrimers
6 жыл бұрын
+dileep Alla sure. Creating a video on that
when i build jar file, I got Communications link failure. i think because we change from localhost to mysql-standalone? how to fix this?
@alimemon9942
4 жыл бұрын
I ran into the same problem after watching this video. Here is the fix stackoverflow.com/questions/59626144/docker-mysql-communication-link-failure
@GauravSingh-pr4lj
4 жыл бұрын
@@alimemon9942 thanx a lot , i was having the same issue
Excelent.... the next step is, deploy to cloud.... are you this video? thanks
Hello Sir, at 15:25 I am getting 'Communication Link Failure'. For me all the steps before 15:25 worked fine. Please help!!
@alimemon9942
4 жыл бұрын
Here is a fix stackoverflow.com/questions/59626144/docker-mysql-communication-link-failure
Nice video, many thing got cleared, Can you please help me one step ahead - I want data even for some MySQL server goes down, still I can get my data back?
@TechPrimers
5 жыл бұрын
You need to take backup and store it outside to restore it back
I am getting unknown database error, can someone please help ?🙂🙏
Can you explane me how did you componse jdbc:mysql://mysql-standalone:3306/test? Is the mysql-standalone the name of the mysql container or from where? ( this is the only part I dont't undestand). Awsome video! Keep going
@Grgarowing
5 жыл бұрын
I have coded a similar application just with postgres. The problem now is when I define jdbc:mysql://mysql-standalone:3306/test with local host instead of mysql.... it works fine untlil the spring boot application is localy runed. When I rune it from a docker container it cannot find the database.
@TechPrimers
5 жыл бұрын
Hi Greg, Yes. mysql-standalone in the docker container name. For postgres, you will have to use a different url (since you need different JDBC driver which supports postgres). Eg something like this - jdbc:postgresql://:/
@Grgarowing
5 жыл бұрын
Tech Primers thanks 😀