Adding Packages to Minimus Images
How to extend a Minimus container image with packages from the MinimOS package repo
Customize Minimus images by adding packages from the MinimOS package repo. This process requires repo credentials in addition to the usual Minimus image pull token. If you need access to repo credentials, please contact your account team.
Note that this is only relevant if you need to add arbitrary packages to images that do not normally include them. Minimus images already include a complete (but minimal) set of packages required to run a given app. However, in your environment you may wish to add some additional package not normally included in the Minimus image. For example, you may wish to add a monitoring tool to the Minimus nginx image. Minimus can create this image and maintain it for you in your private image gallery or you can use this article to create and maintain this image yourself.
Shell example
In the following example, we will add an nginx package to the Minimus Redis image.
To begin, run the dev version of the image so that you have a shell included. You need to run the container as root and override the entrypoint to start up in a shell:
Run whoami
to confirm that you are running as root:
Provide the MinimOS package repository URL as a package source. Your Minimus account team will provide the repo user and password credentials.
Check for updates:
You should see a confirmation with the number of packages found:
Add the nginx package from MinimOS:
You should see the installation messages specifying the package version and dependencies, for example:
Dockerfile example
The following example shows how to utilize the package manager during the build process with Dockerfile. Authentication to the MinimOS package repo is required:
- The first example uses hardcoded credentials for the sake of simplicity. This should only be used in a demo or basic testing environment.
- The second example offers a secure method for passing build secrets to Dockerfile. Refer to Docker documentation to learn more about build secrets
As a first step, always login to the Minimus registry using your Minimus token. This will allow you to pull images from the Minimus registry:
Exposed build arguments
This Dockerfile illustrates how to utilize the package manager during the build process. The credentials are hardcoded:
When you build the app, you will need to pass the repository username & password as build arguments:
Protect build secrets
As a best practice, pass credentials to the MinimOS package repo using a credentials file.
-
Create a text file to store the credentials, for example
repo_credentials.txt
. Add the repo user and repo password as key values in the following format: -
In the Dockerfile, use the flag
--mount=type=secret
and reference the fileid=repo_credentials.txt
: -
When you build the image, reference the credentials file. Note that the period
.
specifies the current directory as the build context: -
Run the image as usual. For example:
docker run redis-with-nginx-test
.Please note that this example utilizes the default NGINX setup. Additional NGINX configurations are needed for a usable app.