Hi All,
I’m new to docker and still learning through documentation. When I saw the documentation, I see “Ubuntu” image being pulled from Hub. I know that the docker directly runs on the Host OS and doesn’t need a guest OS.
If that is the case why are we downloading Ubuntu image again?
Can we not ‘run’ a container by directly installing the application that we want to use?
Please explain.
The docker containers filesystem is isolated from the host OS. So an application packaged inside a docker image wont be able to see the host filesystem(unless attached as volume) at the time of running as a container. So, imagine the application you have inside the container depends on various OS libraries, so maintaining the isolation if we want to run the application we will have to package those dependencies too inside the Docker Image. This is why there are base images available for various Linux distros. Also having a distro will give us its package management features like yum/apt-get so that we can design the docker image with required dependencies in much easier way. And the ubuntu image you are referring is not a full blown one, its a stripped down version of Ubuntu even though its not the smallest docker image available. Also these docker images doesn’t come with a kernel, at runtime, it uses the host kernel.
Now there is a different scenario where you can run your application inside an empty container. There is a special docker image named scratch available using which you can build your docker image.But in the case the application should be a static binary which comes with all the dependencies built into the binary.
If we need Ubuntu or any other OS then how Docker is different from vagrant or running any other VM over Virtual Box, as far as the development environments are concern?
Thanks a lot Ranjan. This is the most clear reply i have come across on this issue on the internet.
Do you have your own website where you write tutorials