Smallest distroless nginx container < alpine

Tanvir Shahid
5 min readAug 22, 2021
Distroless nginx Vs Alpine stable nginx

Previously I wrote why (here, here and here) distroless container is a nice tool to try for container app and make application’s memory requirement more cheaper, slimmer and inexpensive.

Now, in this post we will see how to make most smallest nginx docker container which is even going to be smaller than alpine nginx.

Let’s assume that you have a nginx container project with a Dockerfile like below:

├── nginx-distroless
│ ├── Dockerfile <- This is where we are going to update
│ ├── nginx.conf <- Your own nginx.conf to overwrite the default
│ └── www.conf <- Your own domain/proxy configuration

Let’s open the Dockerfile and update as follows:

# This is a production nginx Dockerfile to produce docker image for production k8s. If you wanna try this Dockerfile in your local environment for testing purpose then you can run as follows:
# docker build -t nginx-distroless .
# To run the above docker container for testing, you can run following command from your terminal:
# docker run -ti --network host nginx-distroless
# On the above `--network host`, we are trying to use host machine's network.FROM debian:buster-slim AS build
WORKDIR /var/www/nginx-distroless
COPY …

--

--

Tanvir Shahid

🦾 Startup mechanic, 💻 Coder, 🧔🏻Techaholic, ₿ Crypto enthusiast, 🍣 Sushi, System architect @ https://retail-ai.jp | https://jp.linkedin.com/in/tanvir-shahid