Is installing OS in Docker incorrect use of Docker?

I am totally new to Docker.

I am currently reading the book ‘Docker deep dive’…and the start of the book describes Docker as solving the problems with VMs… “of having to load a whole OS that is tens of gigabytes in size inside a VM”.

In subsequent chapters he then goes on to spin up the first Docker example using an image of Ubuntu.

I am now confused, and it’s not been clarified in the book if there is any difference in the docker image of Ubuntu vs a regular install of Ubuntu.

But does loading an OS inside a docker image equate to bad practice or is there something I have not understood?

Be grateful for any clarification

Your understanding is correct, but the official images are not full operating systems. Think of a docker image as a collection of binaries, and libraries organized in a file system. The official images (like Ubuntu, CentOS, Debian, etc…) are the minimal binaries and libraries that those OS’s require. So, in the case of Ubuntu, things like bash, aptitude, glibc, etc… If you run “docker pull Ubuntu”, then “docker images”, you’ll see the image is quite small when compared to a full install of Ubuntu.

Ideally, containers are minimal. They require exactly what is required to get your application running inside them, and nothing more. This helps keep them portable, and ephemeral.

Does that help?

Thank you very much for your reply, that is immensely helpful to know.

I was sure there would be a reason behind the numerous OS’s present on the Docker hub and your explanation has cleared that up for me.

Also I was concerned because I had overheard an OPs team member scolding a developer for using the official Ubuntu image inside a Docker container and even though I was sure there was a reason that these operating system images exist I didn’t know enough to understand the reasons for and against

Thanks again!