Purpose of FROM command - Docker file
Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.
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
add a comment |
Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.
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
add a comment |
Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.
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
Main purpose of Docker container is to avoid carrying guest OS in every container, as shown below.
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
docker dockerfile
edited Jan 2 at 1:11
overexchange
asked Jan 2 at 0:58
overexchangeoverexchange
3,76062882
3,76062882
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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.
Assume Windows as host OS, if I launch container by sayingFROM 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
add a comment |
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.
"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
add a comment |
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Assume Windows as host OS, if I launch container by sayingFROM 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
add a comment |
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.
Assume Windows as host OS, if I launch container by sayingFROM 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
add a comment |
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.
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.
edited Jan 2 at 1:33
answered Jan 2 at 1:28
Max♦Max
3,39883651
3,39883651
Assume Windows as host OS, if I launch container by sayingFROM 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
add a comment |
Assume Windows as host OS, if I launch container by sayingFROM 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
add a comment |
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.
"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
add a comment |
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.
"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
add a comment |
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.
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.
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
add a comment |
"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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 2 at 1:44
Richard BarberRichard Barber
26316
26316
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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