3

I have trouble understanding this concept. I know a little bit about how Docker works and what the benefits are, and while I understand running web servers, databases and development environments in containers, I don't understand the point of running an OS like Ubuntu in Docker.

Can someone explain why you would want to do that and also the benefits of an entire OS in a container?

OldMcDonald
  • 594
  • 13
  • 36
  • 1
    Why downvote this question? It is a basic, but a completely valid question for a person trying to get to grips with containers. – 00prometheus Aug 05 '19 at 13:04

2 Answers2

5

The OS is essentially the runtime environment required to run your app. If you app is compiled to run on Linux, it relies on Linux libraries (libc, glib, and so on) that must be present in executing environment, regardless of its type. Docker makes no exception to this.

So a Ubuntu application requires a Ubuntu image in order to run correctly.

Note that Docker container does not include nor run an entire OS, but only the minimum set of libraries that allow your app to run. In particular it does never contain or execute a kernel, as it runs under the host kernel.

Mario Cianciolo
  • 1,223
  • 10
  • 17
  • Thank you very much. So if I want to run an ubuntu application, I would need it to run in the same Ubuntu container? And I would assume that the images with nginx already have the libraries needed? – OldMcDonald Mar 05 '18 at 11:54
  • 1
    There are Ubuntu images for each Ubuntu version. Yes, you should stick to the version you used to build the app. nginx container is based off debian Stretch or Alpine Linux (you can choose). If you application does not have Ubuntu-specific features (often it doesn't) it should run fine on Debian as well. – Mario Cianciolo Mar 05 '18 at 12:12
1

Docker doesn't have its own OS, it is installed on a machine and this allows it to share host operating system resources. There will be only one OS and all the containers will be using that OS. Most of the application are meaningless without OS since it is required for IO, hardware calls etc. Each docker container may have different packages (java, python, jboss etc), applications installed.

Ubercool
  • 1,029
  • 2
  • 14
  • 29