Deploy Spring Boot and MongoDB as Containers Using Docker Command & Docker-Compose | JavaTechie

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2024
  • In this tutorial I’m going to explain how to Deploy Spring Boot and MongoDB as Containers Using Docker Command & Docker-Compose
    #javatechie #SpringBoot #Docker #MongoDB #Docker-Compose
    GitHub:
    github.com/Jav...
    Blogs:
    / javatechie4u
    Facebook:
    / 919464521471923
    guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
    Disclaimer/Policy:
    --------------------------------
    Note : All uploaded content in this channel is mine and its not copied from any community , you are free to use source code from above mentioned GitHub account

ความคิดเห็น • 97

  • @manukumarkm9304
    @manukumarkm9304 ปีที่แล้ว +3

    Clearly explained , with hands on coding example . your tutorials are best .

  • @chaitanyajamadagni
    @chaitanyajamadagni 2 ปีที่แล้ว +2

    Crisp and Clear explanation..Awesome content..Kudos..Way to go !!

  • @VijayKumar-sv3zd
    @VijayKumar-sv3zd ปีที่แล้ว +1

    you made life of a software developer so easy

  • @achintyamukherjee592
    @achintyamukherjee592 2 ปีที่แล้ว +1

    Seedhi baat..no bakwas..keep it up

  • @safdarahmed3778
    @safdarahmed3778 10 หลายเดือนก่อน +1

    Why run MongoDb in docker container if we can connect the spring boot app with remote mongo cluster ?

  • @q3antonio
    @q3antonio 5 หลายเดือนก่อน +1

    Thank you. You've helped me so much!

  • @tonycavanagh1929
    @tonycavanagh1929 ปีที่แล้ว +1

    Thank you very much that works. I spent an entire day trying to get it working on my mongodb client service that called the MongoDB
    I was using
    environment:
    - MONGO_URL=mongodb://mongocontainer:27017/transactions
    Kept failing
    replace with
    link
    mongocontaine amend the appliction.yml to use data, and it works. Its just annoying that the docs did not list your way.
    Thanks again.

  • @jasper5016
    @jasper5016 2 ปีที่แล้ว +3

    Dear Basant, this entire Docker series is fantastic. You can simplify the topics in a such way that even kids can understand it easily. Just one question - if I have to execute it for Postgres or MySQL, will the process same or do I need to change anything?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +2

      No buddy you need to either use docker compose or kuhernetes deployment and service object for your database

    • @jasper5016
      @jasper5016 2 ปีที่แล้ว +3

      @@Javatechie Thanks. I will start Kubernetes soon.

  • @swarnalathananna7053
    @swarnalathananna7053 2 ปีที่แล้ว +1

    Very Helpful.. Great job you are doing. Thank you

  • @vinayhinukale5459
    @vinayhinukale5459 3 ปีที่แล้ว +2

    It refreshed all my docker skills :D

  • @kabira__shaikh
    @kabira__shaikh 3 ปีที่แล้ว +1

    Thank you Basant for the videos.

  • @RaviSavarapu
    @RaviSavarapu 2 ปีที่แล้ว +1

    Thank you . it is very helpful...
    How to use docker compose in production. It creates new container every time .

  • @gotocoding
    @gotocoding 3 ปีที่แล้ว +1

    Thanks Techie

  • @yashwantmhamane6480
    @yashwantmhamane6480 ปีที่แล้ว

    to create jar files why u r doing install u can use package and run it. Also 15:52 to dockerise we can use docker compose file

  • @sonusweetychoda2532
    @sonusweetychoda2532 3 ปีที่แล้ว +1

    simply outstanding basant!!

  • @ai_brain_
    @ai_brain_ 2 ปีที่แล้ว +1

    Thank you so much, you helped me a lot 🙏

  • @vengateshm2122
    @vengateshm2122 2 ปีที่แล้ว +1

    Thank You Very Much. Excellent content. Kudos , Keep it up.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @mohamedely3987
    @mohamedely3987 ปีที่แล้ว +1

    Where were u man ? Thank you so very much!

  • @nutrisport9884
    @nutrisport9884 2 ปีที่แล้ว +1

    Thanks a lot! Very helpful...

  • @shop.edeals4us277
    @shop.edeals4us277 3 ปีที่แล้ว +1

    very helpful. Thank you very much.

  • @rajish15
    @rajish15 3 ปีที่แล้ว +1

    Awesome ❤️ ... Learning a lot from u sir . ☺️

  • @abhijitprusty
    @abhijitprusty 3 ปีที่แล้ว +1

    rocking....as usual..bhai :)

  • @ogabeksaidov1986
    @ogabeksaidov1986 3 ปีที่แล้ว +1

    It's just amazing !!

  • @meenag975
    @meenag975 2 ปีที่แล้ว +1

    Thank you very much !!

  • @allchannel5985
    @allchannel5985 3 ปีที่แล้ว +1

    The best

  • @tusarranjanpati1254
    @tusarranjanpati1254 3 ปีที่แล้ว +1

    Nice....Thank You

  • @WariorrOfGame
    @WariorrOfGame 3 หลายเดือนก่อน

    How does your docker compos understand what spring-mongoDB image is? Do you need to create it before that? how can you do without an image with just docker-compose?

  • @azizkaratas7747
    @azizkaratas7747 26 วันที่ผ่านมา

    Maybe you dont know you should create controller and service folder and you can apply solid principle

  • @tuweiIsaac
    @tuweiIsaac 3 ปีที่แล้ว +1

    great.really helpful

  • @Raj-hm6qi
    @Raj-hm6qi 3 ปีที่แล้ว +1

    Thanks for the video bro

  • @ashishbajpayi4
    @ashishbajpayi4 2 ปีที่แล้ว +1

    Awsome work bro, just has a question about how the spring boot application which is running locally is interacting with the MongoDB instance which is running into the container.
    1) Like you have used the localHost URL and accessed the MongoDB containerized application how is it gets possible?
    2) And also this tutorial is about two containerized applications linked and interacting with each other right.?
    Will be very much thankful if you will address this with me.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      If you observe I link my spring boot image with mongo db image .

    • @ashishbajpayi4
      @ashishbajpayi4 2 ปีที่แล้ว

      @@Javatechie : Yes, then I am confused over there, as we are calling mongo DB image or container with local host application and not with spring boot image/container right.?
      As you have linked --link two containers then how can localhost application interact with the containerized application.?

    • @bogdanvladguta6144
      @bogdanvladguta6144 ปีที่แล้ว

      @@Javatechie is the link necessary? why not putting them in the same network?

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Yes Linkin both images is mandatory

  • @tariqahsan
    @tariqahsan 2 ปีที่แล้ว

    Great video tutorial! Have a question about connecting to an existing database e.g. MySQL or a NoSQL db like MongoDB through Docker. How can we get to do it? Thanks again for your very useful videos.

  • @pareeks
    @pareeks 2 ปีที่แล้ว +1

    Thanks!

  • @manirsg9641
    @manirsg9641 3 ปีที่แล้ว

    Helpful content...It would be great if you could create video on aws mock testing using local stack or how we can test Kubernetes as a Junit?

  • @rahman_darb
    @rahman_darb 3 ปีที่แล้ว +1

    Thanks javatechie

  • @sundarrajagopal4639
    @sundarrajagopal4639 2 ปีที่แล้ว +1

    Thanks

  • @TheDevOpsGuru
    @TheDevOpsGuru ปีที่แล้ว +1

    Book db is not getting created after Linking in mongodb, kindly help.

    • @Javatechie
      @Javatechie  ปีที่แล้ว +1

      Is connection established successfully?

    • @TheDevOpsGuru
      @TheDevOpsGuru ปีที่แล้ว +1

      Actually I was not hitting the db using postman so it was not getting created there. Thanks for your quick response.

  • @rajish15
    @rajish15 3 ปีที่แล้ว +1

    We have 3 microservices running if we have separate docker file ...then we have to use docker compose to link these 3 micro services ? To work as a single unit/ for communication ?

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว +1

      We can handle same with kuhernetes

    • @rabindrakumar949
      @rabindrakumar949 3 ปีที่แล้ว +1

      Yes you can use docker compose if you don't have k8s.

  • @pjj7466
    @pjj7466 ปีที่แล้ว +1

    🥰

  • @VijayKumar-sv3zd
    @VijayKumar-sv3zd ปีที่แล้ว

    After entering the in mongo using -it bash, Inside bash mongo command is not found

  • @nutrisport9884
    @nutrisport9884 2 ปีที่แล้ว +1

    Excelente tutorial. The API works, but when I try to call the API from my front, I have CORS error. Could you please helme?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      You need to enable cors from backend . Use below poc
      @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE").allowedOrigins("*") .allowedHeaders("*"); } }; }

  • @anubhavnigam7611
    @anubhavnigam7611 3 ปีที่แล้ว +1

    Just a small question if I run spring boot application locally without creating its container and try to connect application with mongo db container specifying localhost in connection url instead of mongo db container name will the connection be established?

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      No if you installed it in your local then you can make connections

    • @anubhavnigam7611
      @anubhavnigam7611 3 ปีที่แล้ว

      @@Javatechie But why?.Its not like 2 different containers running with isolated networks and link is then established between them using --link command .I think when you were running the application on ide you were getting an error because container name was provided if instead you would have provided localhost there wouldn't have been any connection error

    • @anubhavnigam7611
      @anubhavnigam7611 3 ปีที่แล้ว

      @@Javatechie could you please provide me an answer of the question I asked ?

  • @abhijitprusty
    @abhijitprusty 3 ปีที่แล้ว +1

    Whenever we run the docker-compose we get this error any idea ? - > pull access denied for springboot-mongodb, repository does not exist or may require 'docker login': denied: requested access to the resource is denied, I ahve already logged in to my account.

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Did you up your docker before you start compose ?

    • @abhijitprusty
      @abhijitprusty 3 ปีที่แล้ว

      @@Javatechie it says this
      Pulling springboot-mongodb (springboot-mongodb:1.0)...
      ERROR: The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.

  • @abhijitprusty
    @abhijitprusty 3 ปีที่แล้ว +1

    need k8s tutorials for local development

  • @gg-zj9vt
    @gg-zj9vt 2 ปีที่แล้ว +1

    Can u plz make a vedio on dockerizing angular+springboot+mongodb, I dockerized successfully springboot+mongodb with the help of this vedio, but I want dockerize angular as well

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      You can checkout my angular dockerize tutorial. already i uploaded it

    • @gg-zj9vt
      @gg-zj9vt 2 ปีที่แล้ว +1

      @@Javatechie I have checked that also , but on how to combine all 3 containers in docker-compose file I have no idea,I have created docker image of angular, I m finding difficulty in combining that in docker compose file, if u can guide me on tat it will be great

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Why are you using docker compose why not kuhernetes

    • @gg-zj9vt
      @gg-zj9vt 2 ปีที่แล้ว

      @@Javatechie I tried to dockerize the full stack project using docker-compose it's working fine, your vedios helped lot thanks 👍, definitely I will kubrnetes also.

    • @gg-zj9vt
      @gg-zj9vt 2 ปีที่แล้ว

      Edit: definitely I will use kubernetes also

  • @PabloQ90
    @PabloQ90 4 หลายเดือนก่อน

    Hi, Im getting 'com.mongodb.MongoSocketOpenException: Exception opening socket' when I try to run the docker container. When I run it in Intellij it works fine

  • @skblabla
    @skblabla 8 หลายเดือนก่อน

    what is the use of -d in docker run command?

    • @Javatechie
      @Javatechie  8 หลายเดือนก่อน

      In Docker, the `-d` flag is used to run a container in detached mode. When you run a container with this flag, it means the container will run in the background, and you'll get the command prompt back in your terminal immediately. This is useful when you don't want the terminal to be tied up by the running container, allowing you to continue using the terminal for other tasks.
      Here's an example:
      ```bash
      docker run -d my_image
      ```
      Without `-d`, the container would run in the foreground, and you would see its output in your terminal.

  • @didierroque7248
    @didierroque7248 3 ปีที่แล้ว +1

    👏🏻👏🏻👏🏻

  • @prateekashtikar8631
    @prateekashtikar8631 2 ปีที่แล้ว

    Even after the docker login getting below error, is there anything missing ?
    % docker-compose up
    [+] Running 0/2
    ⠿ springboot-mongodb Error 6.7s
    ⠿ javatechiemongodb Error 6.7s
    Error response from daemon: pull access denied for springboot-mongodb, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

  • @abhijitprusty
    @abhijitprusty 2 ปีที่แล้ว

    My boot is running on 8083 i used this - docker run -p 8083:9090 --name demoserver --link apmongodb:mono demoserver :1.0-new, stil not able to access the API - Any help ?

  • @rabindrakumar949
    @rabindrakumar949 3 ปีที่แล้ว +1

    Why host name is not ip. How it works by using logical name. How link works. From openjdk 8, which jre it uses. I guess jre version might be different between local and container. If yes how the .class is not complaining about version error.

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Container will setup the environment as information provided in docker file

    • @rabindrakumar949
      @rabindrakumar949 3 ปีที่แล้ว

      @@Javatechie something on networking side we have to know.

  • @marydasjohnson1172
    @marydasjohnson1172 2 ปีที่แล้ว +1

    Mvn install failed and jar not creating due to unknown mongo db host

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Configure Mongo properties correctly

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Please configure mongo properties correctly

    • @marydasjohnson1172
      @marydasjohnson1172 2 ปีที่แล้ว

      @@Javatechie it's worked ,thanks bro

  • @pratishrutipanda6461
    @pratishrutipanda6461 3 ปีที่แล้ว +1

    Thanks for this video

  • @abhijitprusty
    @abhijitprusty 2 ปีที่แล้ว +1

    How do we connect to mongo db which is running without docker ?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Is your application running in container or outside container ?

    • @abhijitprusty
      @abhijitprusty 2 ปีที่แล้ว +1

      @@Javatechie boot application on container and mongo db on windows local instance..i want to try this model...

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      No I don't think it's possible . Your DB instance must need to be run in container platform

  • @pixo-pixel
    @pixo-pixel 2 ปีที่แล้ว

    can you make same for mysql

  • @MoeShammout
    @MoeShammout 2 ปีที่แล้ว

    Hello - Thank you for this useful video.
    When running the app container and linking it with mongodb container, I am getting this error:
    com.mongodb.MongoSocketOpenException: Exception opening socket
    Caused by: java.net.ConnectException: Connection refused (Connection refused)
    Any idea what could this be caused by?

    • @MoeShammout
      @MoeShammout 2 ปีที่แล้ว +1

      I think it is something to do with the yml file. Did you create the Book database in Mongodb container before you ran the application container or was it automatically created based on the configuration in yml file?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      No database will auto create

    • @MoeShammout
      @MoeShammout 2 ปีที่แล้ว

      @@Javatechie
      Thank you. In the video you created the DB Docker image with a fresh instance of Mongodb. How was the Book DB created? Was that done outside the video?

    • @hamzaelmhoujab2350
      @hamzaelmhoujab2350 2 ปีที่แล้ว +1

      @@MoeShammout let me save you some time ;) in application.properties name mongodb host same as your mongo container (in this video : javatechiemongodb) and not localhost because In a container localhost address itself but your mongodb is not in that container

    • @Luukkaaasss
      @Luukkaaasss ปีที่แล้ว

      @@hamzaelmhoujab2350 I've that issue event with the same name instead of localhost

  • @Humani11
    @Humani11 ปีที่แล้ว

    Nice content but video quality is not good