Should each docker image contain a jdk?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
8
down vote

favorite
3












So, I'm very new to Docker. Let me explain the context to the question.



1) I have 10 - 20 spring boot micro-service applications each running on different ports on my local machine.



2) But for migrating to docker, based on my learning, each of this service must be in a different Docker Container so as to quickly deploy or make copies.



3) For each Docker Container , we need to create a new Docker image.



4) Each Docker image must contain a JRE for the spring boot application to run. It is around 200MB max. That means each docker image is, say 350MB at max.
On the other hand, on my local PC I have only 1 JRE of 200MB and each application takes only a few MB of space.



5) Based on this,I would need 600MB on my local system, yet need 7GB for all Docker images.



Is this approach correct? Should "OpenJDK" from DockerHub be added to each image?
Why is the size of image large even if the target PC may already have JDK?










share|improve this question

























    up vote
    8
    down vote

    favorite
    3












    So, I'm very new to Docker. Let me explain the context to the question.



    1) I have 10 - 20 spring boot micro-service applications each running on different ports on my local machine.



    2) But for migrating to docker, based on my learning, each of this service must be in a different Docker Container so as to quickly deploy or make copies.



    3) For each Docker Container , we need to create a new Docker image.



    4) Each Docker image must contain a JRE for the spring boot application to run. It is around 200MB max. That means each docker image is, say 350MB at max.
    On the other hand, on my local PC I have only 1 JRE of 200MB and each application takes only a few MB of space.



    5) Based on this,I would need 600MB on my local system, yet need 7GB for all Docker images.



    Is this approach correct? Should "OpenJDK" from DockerHub be added to each image?
    Why is the size of image large even if the target PC may already have JDK?










    share|improve this question























      up vote
      8
      down vote

      favorite
      3









      up vote
      8
      down vote

      favorite
      3






      3





      So, I'm very new to Docker. Let me explain the context to the question.



      1) I have 10 - 20 spring boot micro-service applications each running on different ports on my local machine.



      2) But for migrating to docker, based on my learning, each of this service must be in a different Docker Container so as to quickly deploy or make copies.



      3) For each Docker Container , we need to create a new Docker image.



      4) Each Docker image must contain a JRE for the spring boot application to run. It is around 200MB max. That means each docker image is, say 350MB at max.
      On the other hand, on my local PC I have only 1 JRE of 200MB and each application takes only a few MB of space.



      5) Based on this,I would need 600MB on my local system, yet need 7GB for all Docker images.



      Is this approach correct? Should "OpenJDK" from DockerHub be added to each image?
      Why is the size of image large even if the target PC may already have JDK?










      share|improve this question













      So, I'm very new to Docker. Let me explain the context to the question.



      1) I have 10 - 20 spring boot micro-service applications each running on different ports on my local machine.



      2) But for migrating to docker, based on my learning, each of this service must be in a different Docker Container so as to quickly deploy or make copies.



      3) For each Docker Container , we need to create a new Docker image.



      4) Each Docker image must contain a JRE for the spring boot application to run. It is around 200MB max. That means each docker image is, say 350MB at max.
      On the other hand, on my local PC I have only 1 JRE of 200MB and each application takes only a few MB of space.



      5) Based on this,I would need 600MB on my local system, yet need 7GB for all Docker images.



      Is this approach correct? Should "OpenJDK" from DockerHub be added to each image?
      Why is the size of image large even if the target PC may already have JDK?







      java docker spring-boot microservices






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      SamwellTarly

      1406




      1406






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          13
          down vote



          accepted










          Your understanding is not correct.



          Docker images are formed with layers, see next diagram:



          When you install a jre in your image, let's suppose it's checksum is 91e54dfb1179 in next picture, it will occupy your disk really.



          But, if all your container then base all the same image, and add different things, says, your different microservice application to the Thin R/W layer, all containers will share the 91e54dfb1179, so it will not be the n*m relationship.



          What you need to pay attention is to use the same base image for all java application as most as possible, and add different things to the Thin R/W layer.



          enter image description here






          share|improve this answer




















            Your Answer





            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52849139%2fshould-each-docker-image-contain-a-jdk%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            13
            down vote



            accepted










            Your understanding is not correct.



            Docker images are formed with layers, see next diagram:



            When you install a jre in your image, let's suppose it's checksum is 91e54dfb1179 in next picture, it will occupy your disk really.



            But, if all your container then base all the same image, and add different things, says, your different microservice application to the Thin R/W layer, all containers will share the 91e54dfb1179, so it will not be the n*m relationship.



            What you need to pay attention is to use the same base image for all java application as most as possible, and add different things to the Thin R/W layer.



            enter image description here






            share|improve this answer
























              up vote
              13
              down vote



              accepted










              Your understanding is not correct.



              Docker images are formed with layers, see next diagram:



              When you install a jre in your image, let's suppose it's checksum is 91e54dfb1179 in next picture, it will occupy your disk really.



              But, if all your container then base all the same image, and add different things, says, your different microservice application to the Thin R/W layer, all containers will share the 91e54dfb1179, so it will not be the n*m relationship.



              What you need to pay attention is to use the same base image for all java application as most as possible, and add different things to the Thin R/W layer.



              enter image description here






              share|improve this answer






















                up vote
                13
                down vote



                accepted







                up vote
                13
                down vote



                accepted






                Your understanding is not correct.



                Docker images are formed with layers, see next diagram:



                When you install a jre in your image, let's suppose it's checksum is 91e54dfb1179 in next picture, it will occupy your disk really.



                But, if all your container then base all the same image, and add different things, says, your different microservice application to the Thin R/W layer, all containers will share the 91e54dfb1179, so it will not be the n*m relationship.



                What you need to pay attention is to use the same base image for all java application as most as possible, and add different things to the Thin R/W layer.



                enter image description here






                share|improve this answer












                Your understanding is not correct.



                Docker images are formed with layers, see next diagram:



                When you install a jre in your image, let's suppose it's checksum is 91e54dfb1179 in next picture, it will occupy your disk really.



                But, if all your container then base all the same image, and add different things, says, your different microservice application to the Thin R/W layer, all containers will share the 91e54dfb1179, so it will not be the n*m relationship.



                What you need to pay attention is to use the same base image for all java application as most as possible, and add different things to the Thin R/W layer.



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                lagom

                2,83021334




                2,83021334



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52849139%2fshould-each-docker-image-contain-a-jdk%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    One-line joke