Prerequisites
When installing packages, make sure to use Minimus containers that meet both conditions:- Can run
apkcommands - Minimusdevimages fit the bill - Run as root - usually this is not the default in Minimus images so you’ll need to switch to a root user
Install packages during runtime (inside a running container)
- Run a Minimus docker container as root and make sure the container includes
apk. For example, you can run the Bash image with thelatest-devtag: - Add packages as usual. For example, you can add
git:Since Minimus images point/etc/apk/repositoriesatpackages.mini.dev/osby default, there’s no need to explicitly point at the MinimOS package repository. This is an example of redundant code that isn’t recommended:
In a Dockerfile
You can install MinimOS packages directly within your Dockerfile during the image build. Since the MinimOS package repository is open to all, there is no need to pass credentials unless you require them. Below is an example of the code to be added to your Dockerfile:Dockerfile code snippet that installs MinimOS public packages
filename
Python tutorial example (multi-stage build)
The following example builds on the multi-stage pattern from the Minimus Python guide. We will follow the steps in the original guide, replacing only the Dockerfile and build command. The Dockerfile uses alatest-dev builder for package installation and Python dependencies and switches to the minimal Python image at runtime.
Dockerfile with apk add steps
apk commands stay in the latest-dev build stage and are executed as USER root to avoid Unable to lock database: Permission denied. The runtime image reg.mini.dev/python:latest is distroless and does not include /bin/sh, so RUN apk ... is not supported there.
Run the build command as usual: