Skip to main content
The apk module manages packages on Alpine Linux systems using the apk package manager.

Functions

packages

Install, remove, or update apk packages.
str | list[str]
List of packages to ensure.
bool
default:true
Whether the packages should be installed.
bool
default:false
Whether to upgrade packages without a specified version.
bool
default:false
Run apk update before installing packages.
bool
default:false
Run apk upgrade before installing packages.
Package versions can be pinned like apk: <pkg>=<version>

Examples


update

Update apk package indexes.
This operation is not idempotent - it will always execute.

upgrade

Upgrade all apk packages.
bool
default:false
Force all packages to be upgraded (recommended on whole Alpine version upgrades).
This operation is not idempotent - it will always execute.

Common Use Cases

Basic System Setup

Container Base Image Setup

Development Environment

Python Development

System Upgrade

Alpine-Specific Tips

Alpine supports virtual packages for build dependencies that can be easily removed:
For latest packages, you may need to use the edge repository:
For minimal container images, use —no-cache: