简体   繁体   中英

Should i build OS in docker?

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?

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(ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM