Setup Alpine Linux on Azure/AWS/GCP
Alpine Linux is a lightweight, security-oriented Linux distribution that is popular for containers, microservices, and cloud workloads. Our pre-built Alpine Linux images are optimized for Microsoft Azure and make it easy to deploy a minimal, fast, and reliable server environment in just a few clicks. To get started, simply choose the deployment link below and launch Alpine Linux directly from the Azure Marketplace.
Getting Started with Alpine Linux
Once your Alpine Linux server has been deployed, the following links explain how to connect to a Linux VM:
- How to connect to a Linux VM on Azure
- How to connect to a Linux VM on AWS
- How to connect to a Linux VM on GCP
Once connected and logged in, you’re now ready to start using your new Linux server.
Upgrade Alpine Linux to Latest Version
To check the current version simply run the following command:
sudo cat /etc/os-release
If you would like to upgrade Alpine Linux to the latest version, run the following bash script:
#!/usr/bin/env bash
# Unattended Alpine Linux upgrade to latest stable
set -euo pipefail
AUTO_REBOOT="${AUTO_REBOOT:-true}"
REPO_FILE="/etc/apk/repositories"
TS="$(date +%Y%m%d-%H%M%S)"
log(){ printf "[INFO] %s\n" "$*"; }
err(){ printf "[ERROR] %s\n" "$*" >&2; exit 1; }
# sanity checks
command -v apk >/dev/null 2>&1 || err "apk not found"
[ -f /etc/alpine-release ] || err "This does not look like Alpine Linux"
# backup and switch repos to latest stable
log "Backing up $REPO_FILE"
sudo cp -a "$REPO_FILE" "${REPO_FILE}.bak.$TS"
log "Rewriting repository URLs to latest-stable"
sudo sed -E -i 's|/v3\.[0-9]+/|/latest-stable/|g' "$REPO_FILE"
# refresh indexes and upgrade everything available
log "Refreshing indexes"
sudo apk update
log "Upgrading all packages to latest available"
sudo apk upgrade --available
# fix any missing deps or moved packages
log "Running apk fix"
sudo apk fix
# optional clean up to reduce image size
log "Cleaning package cache"
sudo rm -rf /var/cache/apk/* || true
# show version info
log "Current release:"
cat /etc/alpine-release || true
uname -r || true
# reboot if requested
if [ "${AUTO_REBOOT}" = "true" ]; then
log "Rebooting now to load any new kernel"
sudo reboot
else
log "Upgrade complete. Reboot recommended"
fi
Documentation / Support
For documentation on using Alpine Linux refer to the official documentation: https://docs.alpinelinux.org/user-handbook/0.1a/index.html
Firewall Ports
To setup AWS firewall rules refer to – AWS Security Groups
To setup Azure firewall rules refer to – Azure Network Security Groups
To setup Google GCP firewall rules refer to – Creating GCP Firewalls
Disclaimer: Alpine Linux is a trademark of the Alpine Linux development team. This solution is based on the official Alpine Linux release and maintained by Cloud Infrastructure Services. Alpine Linux is composed of many open-source components under various licenses (GPL, MIT, BSD, etc.). This solution is not affiliated with or endorsed by the Alpine Linux project. No warranty of any kind, express or implied, is provided with this image.
