Answer the question
In order to leave comments, you need to log in
Why does a Docker container need a base OS image?
New to Docker. I didn't understand one thing.
For example, I need to run nginx in a container. Let's say the host system is ubuntu 16. If I do:
sudo docker run nginx
then nginx, if I understand correctly, will start as if running ubuntu 16?
And if I need to run nginx of the version that was the main one in the ubuntu 14 environment, then what should I do? Create container from ubuntu 16 image and then apt install nginx? Or somehow start the container immediately with the desired version of nginx?
What's the point of running a container based on a base OS image like ubuntu?
Answer the question
In order to leave comments, you need to log in
In an empty (scratch) image there is suddenly nothing.
The OS distribution kit, in addition to the bare kernel, still consists of a set of standard libraries and utilities.
If you were to look at Docker Hub, you might know that the official nginx images are built from debian:buster-slim
.
Create container from ubuntu 16 image and then apt install nginx?On the second link, you can see that in addition to just installing the package, you also need to clean up all temporary files and switch the output of logs.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question