Appreciate if someone could clarify this.
If I understand it correctly, containers share OS from the server and that it doesn’t need OS installed in it unlike VM.
But , I’ve seen some dockerfiles with statements like “FROM ubuntu” and I"m confused with this. Why do we need to install OS in a container when it can share the server’s OS?
The container is managed by the host OS kernel, it does not share the actual OS. You don’t “install” an OS, it’s inherited from the base image (FROM alpine:3.6, for example), so you will see ALL Dockerfiles with a FROM statement.
Here’s some basic reading: https://docs.docker.com/get-started/#images-and-containers