Search code examples
linuxamazon-web-servicesdockerdockerfiledocker-machine

Which docker OS base image should I use?


I am creating a container based on images of a specific operating system have its particularities, since size and packages and other considerations.

In my case, the container will run in AWS, which I could deploy with any Linux distribution, which leads to my question.

Which Linux distribution is better to base my image? Considering that I don't have any dependency to be satisfied, any overview would be appreciated.


Solution

  • Alpine Linux, because you can have advantages in cross-iaas, size, efficiency and security - one interesting point is that docker community are moving their images to be based on Alpine.

    • Cross-IaaS: You can use it in every IaaS (GCP, Azure) with no extra costs.
    • Size: It’s not uncommon for an Alpine-based image to be 1/10 the size of a similar container that is based on other popular base images (Debian, Ubuntu, or CentOS, Amazon Linux, etc). You can do a benchmark with it.
    • Efficiency: Alpine is based on musl(which is a more cleaner code) instead of glibc. A clean and simplier code usually is faster, you can see this discussion.
    • Security: As Alpine has a minimum core of packets, there’s less things that could have vulnerabilities. This is why it is so small - it's built with security on it's purpose. Also, the security footprint (and number of vulnerability announcements) for musl is significantly lower than glibc.

    If you want to do some tests by your own, you can use LayeredInsight(Image Scanner) with a simple php package: php:7.2.0 vs php:7.2.0-alpine3.6, Alpine version has 0 vulnerabilities.

    Deeper discussions: