New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should I start with a Alpine base image, or stick with Debian, Ubuntu, CentOS, etc.? #28

Open
BretFisher opened this Issue Jun 18, 2018 · 1 comment

Comments

1 participant
@BretFisher
Copy link
Owner

BretFisher commented Jun 18, 2018

A common set of related questions:

Do I really need a full OS in the container? Don't I just want the app and its dependencies?

I hear Alpine is minimal and focused on security. I thought containers were supposed to be small and lightweight. Should I switch all my images to using Alpine?

@BretFisher

This comment has been minimized.

Copy link
Owner

BretFisher commented Jun 18, 2018

Some quick answers:

  • Yes a container could be a single binary. This is common in the Go programming language (or C, C++, etc.) where you can build a static binary that has all its dependencies included. Node, PHP, C#, Java, etc. all need their runtime compilers and lots of other dependencies in the container to run, so they usually have their own base images with all the typical dependencies.
  • Remember that for installing dependencies in a container during build-time, you'll likely need package managers. All official base images have package managers in them, so you can easily install internet packages (apt, yum, or apk depending on the distribution they are based on).
  • Official images default the Debian distro with the apt (apt-get) package manager. You can switch to using the Alpine version on most of them by doing image:alpine. Check their Docker Hub README for details.
  • Alpine is a great project, and indeed is very small. For example, the default Debian-based nginx:latest is currently 109MB, while nginx:alpine is only 18MB. The downside is that Alpine has a different package manager (apk) with not all of the same packages as apt or yum, and it also has a different C library which makes it harder to use out of the box sometimes.
  • My recommendation for new people is to always use the base image you are used to in VM's. Do you normally deploy software on Debian/Ubuntu? Then use the default images which come with apt. That means your current install documentation (shell scripts, etc.) will still work inside the Dockerfile where the package manager, file paths, and configs are the same. If you were to pick a Alpine image then you'd have to change all the install commands, find compatible packages (the names are often different, or they just don't exist in Alpine yet). This can add delay to your projects so I typically recommend teams tackle "shifting to a minimal Linux distro" as a later project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment