Ulimits in Docker host vs container












9















I wasn't able to find straight answer, to this question, but here it is:



Let's say that I have a host which has max open files 1024:



[root@host]# ulimit -a
open files (-n) 1024


and a docker container running in that host with:



[root@container]# ulimit -a
open files (-n) 1048576


So will I have a problem in container if I try to open more then 1024 files? I think real limit in this case for container will be 1024 files. What do you think?










share|improve this question





























    9















    I wasn't able to find straight answer, to this question, but here it is:



    Let's say that I have a host which has max open files 1024:



    [root@host]# ulimit -a
    open files (-n) 1024


    and a docker container running in that host with:



    [root@container]# ulimit -a
    open files (-n) 1048576


    So will I have a problem in container if I try to open more then 1024 files? I think real limit in this case for container will be 1024 files. What do you think?










    share|improve this question



























      9












      9








      9


      3






      I wasn't able to find straight answer, to this question, but here it is:



      Let's say that I have a host which has max open files 1024:



      [root@host]# ulimit -a
      open files (-n) 1024


      and a docker container running in that host with:



      [root@container]# ulimit -a
      open files (-n) 1048576


      So will I have a problem in container if I try to open more then 1024 files? I think real limit in this case for container will be 1024 files. What do you think?










      share|improve this question
















      I wasn't able to find straight answer, to this question, but here it is:



      Let's say that I have a host which has max open files 1024:



      [root@host]# ulimit -a
      open files (-n) 1024


      and a docker container running in that host with:



      [root@container]# ulimit -a
      open files (-n) 1048576


      So will I have a problem in container if I try to open more then 1024 files? I think real limit in this case for container will be 1024 files. What do you think?







      docker containers ulimit






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 7:51









      informatik01

      13.2k85691




      13.2k85691










      asked Sep 14 '17 at 5:56









      os11kos11k

      582618




      582618
























          2 Answers
          2






          active

          oldest

          votes


















          5














          Although its a little bit late, I just want to clear the doubts about the difference in ulimit.



          If you do net set the value when running the container, the ulimit value displayed within the container comes from the host OS. The question is then why are you seeing a different value when running the same command from the host?



          This is because when running the command in the host, it is showing its soft limit. On the other hand, the value that the container is showing is the hard limit of the host OS. The reason for this is you are allowed to cross the soft limit. So in a sense, hard limit is actually the real limit. You can find more about ulimit in this link.



          To see the hard limit just type the following command



          ulimit -Hn


          You will see that the values match.



          N.B. You can not cross the hard limit but you can increase it if you are the root.






          share|improve this answer

































            7














            The real limit will be 1048576.



            Have a look at the right part of this image, which shows that containers are basically just isolated processes, running on the same operating system:



            Containers vs. VMs



            As every system call in the container will be handled directly by the host OS, the ulimit that is displayed (1048576) comes directly from the host OS and that is the value that will be used.



            The difference in the ulimits could have been caused by a Docker configuration, for example.



            (Note that for VMs, this will be different: The guest OS might display a value of 1048576, but the open calls will in the end be handled by the host OS, which will impose the limit of 1024)






            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',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              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%2f46211558%2fulimits-in-docker-host-vs-container%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              5














              Although its a little bit late, I just want to clear the doubts about the difference in ulimit.



              If you do net set the value when running the container, the ulimit value displayed within the container comes from the host OS. The question is then why are you seeing a different value when running the same command from the host?



              This is because when running the command in the host, it is showing its soft limit. On the other hand, the value that the container is showing is the hard limit of the host OS. The reason for this is you are allowed to cross the soft limit. So in a sense, hard limit is actually the real limit. You can find more about ulimit in this link.



              To see the hard limit just type the following command



              ulimit -Hn


              You will see that the values match.



              N.B. You can not cross the hard limit but you can increase it if you are the root.






              share|improve this answer






























                5














                Although its a little bit late, I just want to clear the doubts about the difference in ulimit.



                If you do net set the value when running the container, the ulimit value displayed within the container comes from the host OS. The question is then why are you seeing a different value when running the same command from the host?



                This is because when running the command in the host, it is showing its soft limit. On the other hand, the value that the container is showing is the hard limit of the host OS. The reason for this is you are allowed to cross the soft limit. So in a sense, hard limit is actually the real limit. You can find more about ulimit in this link.



                To see the hard limit just type the following command



                ulimit -Hn


                You will see that the values match.



                N.B. You can not cross the hard limit but you can increase it if you are the root.






                share|improve this answer




























                  5












                  5








                  5







                  Although its a little bit late, I just want to clear the doubts about the difference in ulimit.



                  If you do net set the value when running the container, the ulimit value displayed within the container comes from the host OS. The question is then why are you seeing a different value when running the same command from the host?



                  This is because when running the command in the host, it is showing its soft limit. On the other hand, the value that the container is showing is the hard limit of the host OS. The reason for this is you are allowed to cross the soft limit. So in a sense, hard limit is actually the real limit. You can find more about ulimit in this link.



                  To see the hard limit just type the following command



                  ulimit -Hn


                  You will see that the values match.



                  N.B. You can not cross the hard limit but you can increase it if you are the root.






                  share|improve this answer















                  Although its a little bit late, I just want to clear the doubts about the difference in ulimit.



                  If you do net set the value when running the container, the ulimit value displayed within the container comes from the host OS. The question is then why are you seeing a different value when running the same command from the host?



                  This is because when running the command in the host, it is showing its soft limit. On the other hand, the value that the container is showing is the hard limit of the host OS. The reason for this is you are allowed to cross the soft limit. So in a sense, hard limit is actually the real limit. You can find more about ulimit in this link.



                  To see the hard limit just type the following command



                  ulimit -Hn


                  You will see that the values match.



                  N.B. You can not cross the hard limit but you can increase it if you are the root.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 25 '18 at 22:53

























                  answered May 3 '18 at 0:42









                  Alim Ul GiasAlim Ul Gias

                  3,31521935




                  3,31521935

























                      7














                      The real limit will be 1048576.



                      Have a look at the right part of this image, which shows that containers are basically just isolated processes, running on the same operating system:



                      Containers vs. VMs



                      As every system call in the container will be handled directly by the host OS, the ulimit that is displayed (1048576) comes directly from the host OS and that is the value that will be used.



                      The difference in the ulimits could have been caused by a Docker configuration, for example.



                      (Note that for VMs, this will be different: The guest OS might display a value of 1048576, but the open calls will in the end be handled by the host OS, which will impose the limit of 1024)






                      share|improve this answer




























                        7














                        The real limit will be 1048576.



                        Have a look at the right part of this image, which shows that containers are basically just isolated processes, running on the same operating system:



                        Containers vs. VMs



                        As every system call in the container will be handled directly by the host OS, the ulimit that is displayed (1048576) comes directly from the host OS and that is the value that will be used.



                        The difference in the ulimits could have been caused by a Docker configuration, for example.



                        (Note that for VMs, this will be different: The guest OS might display a value of 1048576, but the open calls will in the end be handled by the host OS, which will impose the limit of 1024)






                        share|improve this answer


























                          7












                          7








                          7







                          The real limit will be 1048576.



                          Have a look at the right part of this image, which shows that containers are basically just isolated processes, running on the same operating system:



                          Containers vs. VMs



                          As every system call in the container will be handled directly by the host OS, the ulimit that is displayed (1048576) comes directly from the host OS and that is the value that will be used.



                          The difference in the ulimits could have been caused by a Docker configuration, for example.



                          (Note that for VMs, this will be different: The guest OS might display a value of 1048576, but the open calls will in the end be handled by the host OS, which will impose the limit of 1024)






                          share|improve this answer













                          The real limit will be 1048576.



                          Have a look at the right part of this image, which shows that containers are basically just isolated processes, running on the same operating system:



                          Containers vs. VMs



                          As every system call in the container will be handled directly by the host OS, the ulimit that is displayed (1048576) comes directly from the host OS and that is the value that will be used.



                          The difference in the ulimits could have been caused by a Docker configuration, for example.



                          (Note that for VMs, this will be different: The guest OS might display a value of 1048576, but the open calls will in the end be handled by the host OS, which will impose the limit of 1024)







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Sep 15 '17 at 6:45









                          user3151902user3151902

                          1,8261221




                          1,8261221






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46211558%2fulimits-in-docker-host-vs-container%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              Xamarin.form Move up view when keyboard appear

                              Post-Redirect-Get with Spring WebFlux and Thymeleaf

                              Anylogic : not able to use stopDelay()