4

I've read that:

Docker is a system for management and deployment of application containers, not operating system containers.

However, in several resources (e.g. around 1:20 into https://www.youtube.com/watch?v=pGYAg7TMmp0) it gives an example of "problems" you might encounter if you've developed a web application on a Windows PC or Mac, and are deploying it to a Linux server.

So, how does Docker help in this situation? If we take a web application I understand Docker could help you make a container with the source, and say a specific version of PHP. But could you specify a target OS for it to run on, if it's different from the server that Docker is running on?

The Docker FAQ (https://docs.docker.com/engine/faq/) says

You can run both Linux and Windows programs and excutables in Docker containers.

Does this mean you need Docker installed on a Linux and Windows machine separately to do this, or is it possible to specify any OS within your Docker image and have any machine run it?

Please can someone explain how - or if - Docker deals with specifying a particular OS for your application?

Andy
  • 5,142
  • 11
  • 58
  • 131
  • You can start reading here to better understand docker concepts: https://stackoverflow.com/questions/25492319/how-do-i-dockerize-an-existing-application-the-basics – Amittai Shapira Aug 31 '17 at 16:02

1 Answers1

6

Docker started as a way to run containers on Linux hosts, and this remains the dominate target for docker containers. Developer environments include an embedded VM to run Linux under the covers on Mac and Windows. Originally this was VirtualBox, but newer releases use xhyve and hyperv. The host OS in all of these are Linux so you are not building your image on one OS and running it on another OS.

Since that start, Docker has expanded target OS's. This requires that you have a docker installation for that OS, and it requires that your image be designed to run on that architecture/OS. This started with other architectures of Linux like arm64, and now zLinux. The Microsoft partnership is a rather large rewrite, partially in Windows itself, but also in the Docker code, and especially in the images designed to run natively on Windows. To run these, you have to change the settings on Docker for Windows to run Windows containers instead of Linux containers, you cannot run them both concurrently on the same host. At present, running Windows binaries can only be done on a Windows host, Microsoft isn't shipping free VMs for Linux hosts. And as a new target platform, it still lags behind in features from the Linux hosts.

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Interesting, thanks for this. The thing which I found confusing was that in the Youtube video I posted the author was citing an example of "problems" deploying a web app to different hosts (without Docker) which had different configurations/software and OS's installed. Given that it's possible to specify things like a version of PHP with Docker, I see how that helps. But in the case of a web app it may behave slightly differently under different OS's (or even variants of an OS such as CentOS vs Debian, or specific version numbers of those OS's etc), so Docker is not really covering all bases? – Andy Sep 01 '17 at 08:35
  • 1
    A better way to think about this: docker is an application isolation and portability technology, the underlying OS is shared. If you need multiple OS's then you need VMs. – BMitch Sep 01 '17 at 11:37