20

I'm getting started with docker by reading some blogs and introduction material.

My understanding is docker can wrap a single application into a standardized container. The container provides a sandbox, all the necessary resources the application needs to run, and the application inside always live within that container. That means I can ship the container to everywhere( different kind of OS or even cloud platforms ) and it should still can be run correctly.

If my understanding is correct, then does that mean maybe microsoft can wrap their office suits into a container and I can install and run it on mac os or linux? And some other nice Mac application can also be shipped to windows and linux?

Aaron Shen
  • 8,124
  • 10
  • 44
  • 86
  • 1
    No, but yes. Everything [Charles Duffy said](http://stackoverflow.com/a/30632589/418413) is correct, but that doesn't stop [some inspiring people from creating very portable desktop applications in containers](https://blog.jessfraz.com/post/docker-containers-on-the-desktop/). – kojiro Jun 04 '15 at 01:01
  • As Charles Duffy says, docker is closely tied to Linux, but do not forget you can use wine to run various Windows software with docker, see the containers at https://registry.hub.docker.com/search?page=3&q=wine&n=25 and particularly "Wine + Visual C++ +Python" https://registry.hub.docker.com/u/ambakshi/wine-x11-vcpython27/, or this one if you want to improve your PowerShell scripts https://registry.hub.docker.com/u/solarkennedy/powershell/ :-) – user2915097 Jun 04 '15 at 06:57

1 Answers1

15

Docker is a user-friendly layer on top of LXC, a set of Linux kernel features allowing namespacing of filesystem configuration, network resources, process tables, and other kernel-mediated resources which were historically global. (It's much closer to FreeBSD jails than it is to kvm or VMware).

These features are very specific to Linux, and an application running in a Docker container is still interfacing directly with the host's Linux kernel (though it only has access to the subset of resources exposed to the namespaces in which it participates). Similarly, opcodes are run directly on the hardware with no emulation on virtualization in place, so hardware differences are not abstracted away either

Docker is thus not a cross-OS (or cross-architecture) portability layer, and it will not successfully hide implementation details from applications which depend on specific kernel versions, much less entirely different operating systems altogether.


Early 2017 Update

Docker now runs on Mac, by bundling a lightweight virtualization stack very similar to kvm on Linux. When running this way, it's actually doing both virtualization and containerization -- the former to run a (single) Linux kernel, the latter to run a series of separate containers within this kernel.

This still means that it's limited to running native Linux apps, and it still doesn't provide a display layer for desktop applications (X11, VNC, or something else along those lines needs to be used in addition). However, by bundling a virtualization tool, modern Docker now is something of a portability solution (across platforms, not architectures).

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Yes. Actually one can try to build something like Docker on top of virtual box to achieve the OP's goal (possibly heavy overhead though). – xuhdev Jun 04 '15 at 01:03
  • What if you use a web interface? It's not X11, VNC, etc., but it is a UI that gets rendered in a web browser on the host. Could you consider this to be a cross-platform solution for writing software? I'm thinking of pgAdmin as an example of what I'm thinking about. I run pgAdmin in a container and it works on both Windows and Mac (and I'm assuming also on Linux). But, it also installs natively on each of these OSs, but a Docker container is an option. – Brandon Aug 26 '21 at 14:48
  • @Brandon, I'd consider that "what if" too opinion-based to be a proper Stack Overflow topic, and thusly, sidestep it :) -- but IMHO, if you're needing to connect to a server in a web browser to access your app, what you're running is no longer a "desktop application". – Charles Duffy Aug 26 '21 at 15:37