---
name: "alpine-chroot-install"
section: "8"
platform: "linux"
package: "alpine-chroot-install"
version: "0.14.0-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/alpine-chroot-install"
---

# alpine-chroot-install(8)

bootstrap an Alpine Linux chroot

## NAME

alpine-chroot-install - bootstrap an Alpine Linux chroot

## SYNOPSIS

**alpine-chroot-install** **-d** */directory* \[*options*\]

## DESCRIPTION

This script installs Alpine Linux into a chroot and optionally sets up qemu-user and binfmt to emulate different architecture (e.g. armhf).

## OPTIONS AND ENVIRONMENT VARIABLES

- **-a ARCH**

  CPU architecture for the chroot. If not set, then it's the same as the host's architecture. If it's different from the host's architecture, then it will be emulated using qemu-user. Options: x86\_64, x86, aarch64, armhf, armv7, ppc64le, riscv64, s390x.

- **-b ALPINE\_BRANCH**

  Alpine branch to install (default is latest-stable).

- **-d CHROOT\_DIR**

  Absolute path to the directory where Alpine chroot should be installed; Debian's version of this script requires giving this explicitly -- such as **-d** */alpine*

- **-i BIND\_DIR**

  Absolute path to the directory on the host system that should be mounted on the same path inside the chroot (default is PWD, if it's under /home, or none).

- **-k CHROOT\_KEEP\_VARS**

  Names of the environment variables to pass from the host environment into chroot by the enter-chroot script. Name may be an extended regular expression. Default: ARCH CI QEMU\_EMULATOR TRAVIS\_.\*.

- **-m ALPINE\_MIRROR**

  URI of the Aports mirror to fetch packages from (default is http://dl-cdn.alpinelinux.org/alpine).

- **-p ALPINE\_PACKAGES**

  Alpine packages to install into the chroot (default is build-base ca-certificates ssl\_client).

- **-r EXTRA\_REPOS**

  Alpine repositories to be added to /etc/apk/repositories (main and community from $ALPINE\_MIRROR are always added).

- **-t TEMP\_DIR**

  Absolute path to the directory where to store temporary files (defaults to \`mktemp -d\`).

- **-h**

  Show this help message and exit.

- **-v**

  Print version and exit.

- **APK\_TOOLS\_URI**

  URL of apk.static to download. Default is x86\_64 binary from https://gitlab.alpinelinux.org/alpine/apk-tools/-/packages.

- **APK\_TOOLS\_SHA256**

  SHA-256 checksum of $APK\_TOOLS\_URI.

Each option can be also provided by environment variable. If both option and variable is specified and the option accepts only one argument, then the option takes precedence.

## AFTER INSTALL

This tool also creates script "enter-chroot" inside the chroot directory, that may be used to enter the chroot environment. That script do the following:

-

  1\. saves environment variables specified by $CHROOT\_KEEP\_VARS and PWD,

  2\. chroots into $CHROOT\_DIR,

  3\. starts clean environment using "env -i",

  4\. switches user and simulates full login using "su -l",

  5\. loads saved environment variables and changes directory to saved PWD,

  6\. executes specified command or "sh" if not provided.

Example:

```
sudo alpine-chroot-install -d /alpine -p build-base -p cmake
/alpine/enter-chroot -u $USER ./build
```
