Purpose of FROM command - Docker file












0















Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.



enter image description here
As mentioned here, The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile must start with a FROM instruction.



My understanding is, FROM <image> allow a container to run on its own OS.





Why a valid Docker file must have FROM instruction?










share|improve this question





























    0















    Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.



    enter image description here
    As mentioned here, The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile must start with a FROM instruction.



    My understanding is, FROM <image> allow a container to run on its own OS.





    Why a valid Docker file must have FROM instruction?










    share|improve this question



























      0












      0








      0


      1






      Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.



      enter image description here
      As mentioned here, The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile must start with a FROM instruction.



      My understanding is, FROM <image> allow a container to run on its own OS.





      Why a valid Docker file must have FROM instruction?










      share|improve this question
















      Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.



      enter image description here
      As mentioned here, The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile must start with a FROM instruction.



      My understanding is, FROM <image> allow a container to run on its own OS.





      Why a valid Docker file must have FROM instruction?







      docker dockerfile






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 1:11







      overexchange

















      asked Jan 2 at 0:58









      overexchangeoverexchange

      3,76062882




      3,76062882
























          3 Answers
          3






          active

          oldest

          votes


















          2














          Containers don't run a full OS, they share the kernel of the host OS (typically, the Linux kernel). That's the "Host Operating System" box in your right image.



          They do provide what's called "user space isolation" though - roughly speaking, this means that every container manages its own copy of the part of the OS which runs in user mode- typically, that's a Linux distribution such as Ubuntu. In your right image, that would be contained in the "Bins/Libs" box.



          You can leave out the FROM line in your Dockerfile, or use FROM scratch, to create a blank base image, then add all the user mode pieces on top of a blank kernel yourself.






          share|improve this answer


























          • Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

            – overexchange
            Jan 2 at 1:57








          • 1





            If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

            – Max
            Jan 2 at 2:11













          • Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

            – Max
            Jan 2 at 2:17











          • So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

            – overexchange
            Feb 2 at 17:10



















          1














          FROM instruction specifies the underlying OS architecture that you are gonna use to build the image. You have to use some form of base image for you to get started with building an image. It can be ubuntu, centos or any minimal linux image like ALPINE which is only 5MB!. The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution. This makes the size of the docker images very small as compared to the full blown OS distribution. I hope this answers your question. Let me know if you have any questions.






          share|improve this answer
























          • "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

            – overexchange
            Jan 2 at 1:29











          • "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

            – Max
            Jan 2 at 1:29











          • Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

            – Varun Babu Pozhath
            Jan 2 at 1:32



















          0














          Another common use of FROM is to chain builds together to form a multi-stage build of smaller images.



          This would be useful for instance to limit redundant rebuilding during failed auto-builds.






          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%2f54000157%2fpurpose-of-from-command-docker-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            Containers don't run a full OS, they share the kernel of the host OS (typically, the Linux kernel). That's the "Host Operating System" box in your right image.



            They do provide what's called "user space isolation" though - roughly speaking, this means that every container manages its own copy of the part of the OS which runs in user mode- typically, that's a Linux distribution such as Ubuntu. In your right image, that would be contained in the "Bins/Libs" box.



            You can leave out the FROM line in your Dockerfile, or use FROM scratch, to create a blank base image, then add all the user mode pieces on top of a blank kernel yourself.






            share|improve this answer


























            • Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

              – overexchange
              Jan 2 at 1:57








            • 1





              If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

              – Max
              Jan 2 at 2:11













            • Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

              – Max
              Jan 2 at 2:17











            • So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

              – overexchange
              Feb 2 at 17:10
















            2














            Containers don't run a full OS, they share the kernel of the host OS (typically, the Linux kernel). That's the "Host Operating System" box in your right image.



            They do provide what's called "user space isolation" though - roughly speaking, this means that every container manages its own copy of the part of the OS which runs in user mode- typically, that's a Linux distribution such as Ubuntu. In your right image, that would be contained in the "Bins/Libs" box.



            You can leave out the FROM line in your Dockerfile, or use FROM scratch, to create a blank base image, then add all the user mode pieces on top of a blank kernel yourself.






            share|improve this answer


























            • Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

              – overexchange
              Jan 2 at 1:57








            • 1





              If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

              – Max
              Jan 2 at 2:11













            • Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

              – Max
              Jan 2 at 2:17











            • So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

              – overexchange
              Feb 2 at 17:10














            2












            2








            2







            Containers don't run a full OS, they share the kernel of the host OS (typically, the Linux kernel). That's the "Host Operating System" box in your right image.



            They do provide what's called "user space isolation" though - roughly speaking, this means that every container manages its own copy of the part of the OS which runs in user mode- typically, that's a Linux distribution such as Ubuntu. In your right image, that would be contained in the "Bins/Libs" box.



            You can leave out the FROM line in your Dockerfile, or use FROM scratch, to create a blank base image, then add all the user mode pieces on top of a blank kernel yourself.






            share|improve this answer















            Containers don't run a full OS, they share the kernel of the host OS (typically, the Linux kernel). That's the "Host Operating System" box in your right image.



            They do provide what's called "user space isolation" though - roughly speaking, this means that every container manages its own copy of the part of the OS which runs in user mode- typically, that's a Linux distribution such as Ubuntu. In your right image, that would be contained in the "Bins/Libs" box.



            You can leave out the FROM line in your Dockerfile, or use FROM scratch, to create a blank base image, then add all the user mode pieces on top of a blank kernel yourself.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 2 at 1:33

























            answered Jan 2 at 1:28









            MaxMax

            3,39883651




            3,39883651













            • Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

              – overexchange
              Jan 2 at 1:57








            • 1





              If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

              – Max
              Jan 2 at 2:11













            • Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

              – Max
              Jan 2 at 2:17











            • So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

              – overexchange
              Feb 2 at 17:10



















            • Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

              – overexchange
              Jan 2 at 1:57








            • 1





              If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

              – Max
              Jan 2 at 2:11













            • Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

              – Max
              Jan 2 at 2:17











            • So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

              – overexchange
              Feb 2 at 17:10

















            Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

            – overexchange
            Jan 2 at 1:57







            Assume Windows as host OS, if I launch container by saying FROM ubuntu in Dockerfile, then these C executables(say /bin/ls, /bin/grep) in this container are mainly linux based binaries(ELF-64). How these binaries(ELF-64) work with windows host OS(COFF format binaries)? with docker daemon in the middle

            – overexchange
            Jan 2 at 1:57






            1




            1





            If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

            – Max
            Jan 2 at 2:11







            If you're running Docker for Windows in Linux container mode, it'll basically run a Linux VM behind the scenes. All your containers share the Linux kernel of that VM (not the Windows kernel).

            – Max
            Jan 2 at 2:11















            Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

            – Max
            Jan 2 at 2:17





            Actually, looks like that's no longer accurate: hanselman.com/blog/… - not quite sure how exactly native Linux Container support on Windows works, it might be somewhat similar to Windows Subsystem for Linux.

            – Max
            Jan 2 at 2:17













            So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

            – overexchange
            Feb 2 at 17:10





            So, FROM command decides, what to go in "Bins/Libs" box according to kernel running on Host OS. Is that correct?

            – overexchange
            Feb 2 at 17:10













            1














            FROM instruction specifies the underlying OS architecture that you are gonna use to build the image. You have to use some form of base image for you to get started with building an image. It can be ubuntu, centos or any minimal linux image like ALPINE which is only 5MB!. The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution. This makes the size of the docker images very small as compared to the full blown OS distribution. I hope this answers your question. Let me know if you have any questions.






            share|improve this answer
























            • "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

              – overexchange
              Jan 2 at 1:29











            • "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

              – Max
              Jan 2 at 1:29











            • Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

              – Varun Babu Pozhath
              Jan 2 at 1:32
















            1














            FROM instruction specifies the underlying OS architecture that you are gonna use to build the image. You have to use some form of base image for you to get started with building an image. It can be ubuntu, centos or any minimal linux image like ALPINE which is only 5MB!. The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution. This makes the size of the docker images very small as compared to the full blown OS distribution. I hope this answers your question. Let me know if you have any questions.






            share|improve this answer
























            • "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

              – overexchange
              Jan 2 at 1:29











            • "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

              – Max
              Jan 2 at 1:29











            • Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

              – Varun Babu Pozhath
              Jan 2 at 1:32














            1












            1








            1







            FROM instruction specifies the underlying OS architecture that you are gonna use to build the image. You have to use some form of base image for you to get started with building an image. It can be ubuntu, centos or any minimal linux image like ALPINE which is only 5MB!. The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution. This makes the size of the docker images very small as compared to the full blown OS distribution. I hope this answers your question. Let me know if you have any questions.






            share|improve this answer













            FROM instruction specifies the underlying OS architecture that you are gonna use to build the image. You have to use some form of base image for you to get started with building an image. It can be ubuntu, centos or any minimal linux image like ALPINE which is only 5MB!. The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution. This makes the size of the docker images very small as compared to the full blown OS distribution. I hope this answers your question. Let me know if you have any questions.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 2 at 1:25









            Varun Babu PozhathVarun Babu Pozhath

            257215




            257215













            • "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

              – overexchange
              Jan 2 at 1:29











            • "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

              – Max
              Jan 2 at 1:29











            • Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

              – Varun Babu Pozhath
              Jan 2 at 1:32



















            • "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

              – overexchange
              Jan 2 at 1:29











            • "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

              – Max
              Jan 2 at 1:29











            • Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

              – Varun Babu Pozhath
              Jan 2 at 1:32

















            "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

            – overexchange
            Jan 2 at 1:29





            "The idea is to install only the packages you need rather than having everything bundled and packaged as a distribution." What exactly are you bundling? If a container has its own kernel, then why would I use docker container?

            – overexchange
            Jan 2 at 1:29













            "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

            – Max
            Jan 2 at 1:29





            "If a container has its own kernel" - it doesn't. The kernel is shared with the host OS.

            – Max
            Jan 2 at 1:29













            Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

            – Varun Babu Pozhath
            Jan 2 at 1:32





            Yes same as what @Max said above. Here Docker daemon manages your kernel and how it utilises the resources available to it .

            – Varun Babu Pozhath
            Jan 2 at 1:32











            0














            Another common use of FROM is to chain builds together to form a multi-stage build of smaller images.



            This would be useful for instance to limit redundant rebuilding during failed auto-builds.






            share|improve this answer




























              0














              Another common use of FROM is to chain builds together to form a multi-stage build of smaller images.



              This would be useful for instance to limit redundant rebuilding during failed auto-builds.






              share|improve this answer


























                0












                0








                0







                Another common use of FROM is to chain builds together to form a multi-stage build of smaller images.



                This would be useful for instance to limit redundant rebuilding during failed auto-builds.






                share|improve this answer













                Another common use of FROM is to chain builds together to form a multi-stage build of smaller images.



                This would be useful for instance to limit redundant rebuilding during failed auto-builds.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 2 at 1:44









                Richard BarberRichard Barber

                26316




                26316






























                    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%2f54000157%2fpurpose-of-from-command-docker-file%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







                    Popular posts from this blog

                    'app-layout' is not a known element: how to share Component with different Modules

                    android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                    WPF add header to Image with URL pettitions [duplicate]