How to fix ERROR: unable to select packages: pkg (no such package) in Docker

DockerBEGINNERMEDIUMUpdated Aug 27, 2026ยท 548 views

This error occurs when Alpine Linux's apk package manager cannot find a package in its repositories. Common causes include missing repository configuration, renamed packages in newer Alpine versions, or typos in the package name.

Quick fix

Fixes ERROR: unable to select packages: pkg (no such package)

FROM alpine:3.19

# Always update before installing
RUN apk update && apk add --no-cache \
    curl \
    git \
    bash
  1. Run apk update before installing packages
  2. Enable the community repository
  3. Verify the correct package name
  4. Pin Alpine version for reproducibility
docker โ€” error
FROM alpine:3.19
# Always update before installing
RUN apk update && apk add --no-cache \
curl \
git \
bash
ERROR: unable to select packages: pkg (no such package)

What this error means

The "unable to select packages: (no such package)" error appears when Alpine's apk package manager cannot locate a requested package in any of its configured repositories. Unlike Debian-based systems that use apt, Alpine uses apk with a different repository structure (main, community, and testing). This error is particularly common in Docker because Alpine base images are minimal and may only include the main repository by default. Many popular packages live in the community repository, which isn't always enabled. Additionally, package names often differ between Alpine versions or may be named differently than you'd expect from other distributions. The error message format `unable to select packages: <package> (no such package)` tells you that apk searched all configured repositories and found no package matching the name you specified.

Typical symptoms

  • Docker build fails with 'ERROR: unable to select packages: <package> (no such package)'
  • The same package installs fine on other Linux distributions but fails on Alpine
  • Build worked previously but fails after updating the base Alpine image
  • Package shows as available on pkgs.alpinelinux.org but won't install

Common causes

  1. Package is in the community repository, which isn't enabled by default
  2. Package name changed between Alpine versions (e.g., python -> python3)
  3. Package was removed or deprecated in newer Alpine releases
  4. Typo in the package name or using wrong package naming convention
  5. Package only exists in edge/testing repository, not in stable releases
  6. Missing apk update before attempting installation

How to fix "ERROR: unable to select packages: pkg (no such package)"

1Run apk update before installing packages

Always refresh the package index before installing. In your Dockerfile:

dockerfile
FROM alpine:3.19

# Always update before installing
RUN apk update && apk add --no-cache \
    curl \
    git \
    bash

The --no-cache flag is preferred in Docker as it combines update and install while keeping the image small by not caching the index locally.

dockerfile
# Preferred pattern for Docker
RUN apk add --no-cache curl git bash
2Enable the community repository

Many popular packages are in the community repository. Enable it in your Dockerfile:

dockerfile
FROM alpine:3.19

# Add community repository
RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.19/community" >> /etc/apk/repositories

# Now you can install community packages
RUN apk add --no-cache nodejs npm

Or use a one-liner that adds the repository and installs in one step:

dockerfile
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.19/community nodejs npm

To check which repository a package is in, visit https://pkgs.alpinelinux.org/packages

3Verify the correct package name

Alpine uses different package names than Debian/Ubuntu. Common examples:

| What you want | Debian/Ubuntu | Alpine |
|---------------|---------------|--------|
| Python 3 | python3 | python3 |
| Python (legacy) | python | python3 (python2 deprecated) |
| AWS CLI | awscli | aws-cli |
| Build tools | build-essential | build-base |
| SSL libs | libssl-dev | openssl-dev |

Search for the correct name at https://pkgs.alpinelinux.org/packages or in a running container:

bash
docker run -it alpine:3.19 sh
apk update
apk search <partial-name>
4Pin Alpine version for reproducibility

Package availability changes between Alpine versions. Pin your version to avoid surprises:

dockerfile
# Bad - may break when Alpine updates
FROM alpine:latest

# Good - predictable behavior
FROM alpine:3.19

# Even better - use full version tag
FROM alpine:3.19.1

If a package you need was removed in a newer version, you may need to use an older Alpine release or find an alternative package.

5Use edge repository for cutting-edge packages

Some packages are only available in Alpine's edge (development) repositories:

dockerfile
FROM alpine:3.19

# Add edge testing repository (use with caution)
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing some-package

Warning: Edge packages may be unstable or break with Alpine updates. For production, prefer:
1. Using a stable Alpine version with the package
2. Building the software from source
3. Using a different base image

6Check for virtual packages and aliases

Alpine uses virtual packages to group related packages. Check if what you need is available under a different name:

bash
# Search for packages providing a specific file or capability
docker run -it alpine:3.19 sh -c "apk update && apk search cmd:python"

# List what a virtual package provides
docker run -it alpine:3.19 sh -c "apk info -R python3"

Common virtual packages:
- build-base - includes gcc, make, musl-dev
- .python-rundeps - Python runtime dependencies
- ca-certificates - SSL certificate authorities

Advanced notes

musl vs glibc: Alpine uses musl libc instead of glibc. Some binaries compiled for glibc won't work. Install gcompat for basic glibc compatibility, or use a glibc-based Alpine variant.

Version-specific repositories: Match your repository URL to your Alpine version. Using mismatched versions (e.g., v3.18 repos on v3.19 base) can cause dependency conflicts:

dockerfile
FROM alpine:3.19
# Use matching version in repository URLs
RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.19/community" >> /etc/apk/repositories

Package version pinning: Pin specific versions when reproducibility matters:

dockerfile
RUN apk add --no-cache nodejs=20.10.0-r1

However, note that Alpine repositories only keep the latest version of each package per branch. Old versions are removed, so pinning may break future builds.

Using packages from older Alpine: If a package was removed but you need it, temporarily add an older repository:

dockerfile
FROM alpine:3.19
# Add 3.18 repository for a specific package
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.18/community libssl1.1

This is a workaround and may cause dependency issues. Prefer upgrading your application to work with newer library versions.

Multi-stage builds: If you only need a package for building (not runtime), use multi-stage builds to keep final images small:

dockerfile
FROM alpine:3.19 AS builder
RUN apk add --no-cache build-base
# Build your application

FROM alpine:3.19
# Only runtime dependencies here
COPY --from=builder /app /app

Frequently asked questions

What does "ERROR: unable to select packages: pkg (no such package)" mean?
The "unable to select packages: (no such package)" error appears when Alpine's apk package manager cannot locate a requested package in any of its configured repositories. Unlike Debian-based systems that use apt, Alpine uses apk with a different repository structure (main, community, and testing). This error is particularly common in Docker because Alpine base images are minimal and may only include the main repository by default.
How do I fix "ERROR: unable to select packages: pkg (no such package)"?
This error occurs when Alpine Linux's apk package manager cannot find a package in its repositories. Common causes include missing repository configuration, renamed packages in newer Alpine versions, or typos in the package name.
What causes "ERROR: unable to select packages: pkg (no such package)"?
Package is in the community repository, which isn't enabled by default Package name changed between Alpine versions (e.g., python -> python3) Package was removed or deprecated in newer Alpine releases
Is the "ERROR: unable to select packages: pkg (no such package)" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading