Should i build OS in docker?

2019-10-20 20:21发布

问题:

I'm creating environment for simple projects on php + apache and i'm new to docker. I don't get the difference between building something like alpine+LAMP or just build a LAMP, all machines running Ubuntu. Do i need an OS?

回答1:

Yes. You need a OS(actually, it's not complete OS. i will explain later). Why? Ok, let me explain.

  1. When you are running your application using Docker, you are running this application inside a container.
  2. This container does not use your OS file system and libraries. Instead, it directly communicate with kernel using syscall.

Now the question is, where you application will get the necessary file system and libraries to run?

Here, the base OS(i.e. alpine image) come into play. This base image is not complete linux OS. It does not have a kernel. It provides a file system and some necessary libraries to run your application.

UPD: However, you can build a docker image that do not require any base OS image(from scratch). But it require that your application must be statically compiled which means it includes all necessary library within the binary that are required to run the application.



标签: linux docker