Reputation: 1212
Reading this question, I understood that containers use a base image (like ubuntu) for root filesystem. Now my question is if is necessary to download a base image, if I have exactly the same OS (like ubuntu 14.04).
Is that base image redundant?
Upvotes: 3
Views: 193
Reputation: 1327902
First, if your service run in that container is statically linked (like a Go application), you could COPY that app in a "scratch" container (which is an empty one! No OS at all)
Second, an app in a container can only make system calls to the host kernel, it doesn't see the host filesystem (beside what is mounted by volumes)
The base image is there to guarantee that the runtime will be reproducible: any user call (dynamic linking) will be done against the exact same OS (base image), even if you have updated/upgraded your base OS.
Finally, a base image "ubuntu" is not the same as an actual Ubuntu OS: it is a compact subset (a root filesystem, without the graphical X-11 part), and it used by docker, with UnionFS, as one of the layers of disk blocks inside a container.
Upvotes: 2