Satya Rao
Satya Rao

Reputation: 159

Are Docker containers tied to the underlying host OS?

As a newbie,I have read the official Docker documentation, and have followed many explanations here, tutorials, videos on this, but have not yet got a clear answer to my question. If a docker container must use the underlying host OS kernel, then how can they claim "build, ship and run anywhere"? I mean, linux-based containers can run only on linux-based host OS machines, and similarly with windows containers. Is this correct, or have I completely missed it? I am not sure there is such a thing as "linux-based containers" and "windows-based containers".

I can see when someone claims that java apps can run on any OS, but dont see how the same claim can be made for docker containers.

Upvotes: 7

Views: 4200

Answers (3)

fractalic
fractalic

Reputation: 417

Don't yet have the karma/streetcred/rep to comment, so I'm writing an answer instead.

First, I don't get why this question is so heavily downvoted, because it's legit and something the docker docs do not straightforwardly answer.

Anyways.

Thanks for taking time to clear up some confusion. So, in the above MS container link, e.g. they say create a Dockerfile and then run "docker build ...". etc. Where exactly is the "docker" application running? On a Windows host? Or on some linux(which flavor/version?) VM that gets created on a windows host? If "docker" is running on a linux VM, then it somehow seems to be able to bypass the linux OS (in the VM) and access the underlying windows OS? Again, I am assuming "docker" is a linux application, and is not a windows port running on a windows host.

In this case, Docker would be a native Windows application (or Windows port), running IIS as a native Windows application.

Think of it like this: the Docker application virtualizes the file system, so that every piece of software that gets installed ends up on this virtual file system. The kernel is not virtualized; so, as other answers said, if you want to transfer a Linux dev environment to a Windows machine, you would need to

run a linux vm on your pc/mac

and then run docker on that vm.

See How is Docker different from a normal virtual machine? for the megathread on Docker de-confusion.

See also http://blog.vizuri.com/docker-for-windows-vs.-docker-on-windows-server which explains the most confusing part of running Docker on Windows. As detailed in the article, you could use Docker on Windows to run Windows containers on Windows, or you could use Docker for Windows to run Linux containers in a Docker-managed Linux vm on windows. The same would be true of Mac ; or indeed, any two incompatible kernels.

Upvotes: 4

Containers isolate applications from each other on the same machine, but you're right, they all use the underlying OS. If you need different OS to run different applications on the same machine, you need to use virtual machines instead. Containers are good because you get everything you need to run an application in a single package, and there's less waste of resources because you're not throwing a whole big OS in there as well.

Note that for development purposes it's not unusual to run containers inside a virtual machine, so for instance you can run a linux vm on your pc/mac, and easily move the containers you develop there into real linux-based production.

Check out the snappy FAQ explanation here: https://docs.docker.com/engine/faq/#how-much-does-engine-cost

Upvotes: 4

CFrei
CFrei

Reputation: 3627

Short answer: Correct. All containers share the same linux kernel. If you depend on a kernel specific features, Docker is not for you. Beside that, there are also Windows based images and theoretically you can bring any host kernel as long as it fulfills the requirements of these guys: https://www.opencontainers.org/

Upvotes: 3

Related Questions