Running a Prometheus server in a Windows Docker container

Prometheus is a cross-platform application, written in Go, which can run on Nano Server. The installer for Prometheus comes as a GZipped Tar file, which you can't natively extract in Windows. To package Prometheus in Docker, I use a multi-stage build, where I download and extract the package in the first stage.

The best tool to extract a GZipped TAR file in Windows is 7-Zip, and I have a Docker image that installs 7-Zip called dockeronwindows/ch11-7zip. The Dockerfile for the Prometheus image dockeronwindows/ch11-prometheus starts using this image and then runs PowerShell cmdlets to download the package and extract it:

RUN Invoke-WebRequest "https://github.com/prometheus/prometheus/releases/download/v$($env:PROMETHEUS_VERSION)/prometheus-$($env:PROMETHEUS_VERSION).windows-amd64.tar.gz" ...

Get Docker on Windows now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.