If your docker build fails with /bin/sh: 1: apt-key: not found or with E: Unable to locate package software-properties-common, your base image has moved to Debian 13 (trixie), which no longer ships apt-key or the package that installed add-apt-repository. The fix is to save the repository key under /etc/apt/keyrings and declare the repository in a .sources file with the Signed-By field. I tested it on 25 November 2026 on arm64 Linux with node:26-slim (Debian 13.8, apt 3.0.4) and compared it with node:26-bookworm-slim (Debian 12.15, apt 2.6.2). There is a Spanish version of this guide.

Key takeaways

  • Debian 13 has no /usr/bin/apt-key and no package brings it back: apt-get install apt-key answers Unable to locate package.
  • software-properties-common is not in trixie, so add-apt-repository does not exist either.
  • The fix is two files: the key in /etc/apt/keyrings/name.asc and a name.sources file with Signed-By. You do not need gnupg.
  • The same fixed Dockerfile works on bookworm and on trixie, so you can correct it before you change the base.
  • The node:lts tag moved to trixie on 28 October 2026; python, php and postgres moved in August 2025.
  • Pinning the -bookworm tag works, but Debian 12 only has Long Term Support (LTS) until 30 June 2028.

/bin/sh: 1: apt-key: not found and E: Unable to locate package software-properties-common

These are the two errors, as docker build prints them on an image with Debian 13. The first one appears with the classic recipe for adding a third-party repository, here Docker's:

FROM node:26-slim
RUN apt-get update \
 && apt-get install -y --no-install-recommends curl ca-certificates gnupg \
 && curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
 && echo "deb https://download.docker.com/linux/debian trixie stable" \
    > /etc/apt/sources.list.d/docker.list \
 && apt-get update \
 && apt-get install -y --no-install-recommends docker-ce-cli

The build stops at the apt-key line, even with gnupg installed. I cut the command that Docker repeats in the message with […]:

5.054 /bin/sh: 1: apt-key: not found
ERROR: failed to build: failed to solve: process "/bin/sh -c apt-get update
[…] docker-ce-cli" did not complete successfully: exit code: 127

The second error shows up when the Dockerfile installs software-properties-common to use add-apt-repository:

1.345 E: Unable to locate package software-properties-common
ERROR: failed to build: failed to solve: process "/bin/sh -c apt-get update
[…]" did not complete successfully: exit code: 100

The variants depend on the shell that runs the line. With docker run and sh I saw sh: 1: apt-key: not found and sh: 1: add-apt-repository: not found. With bash the text changes to bash: line 1: apt-key: command not found and bash: line 1: add-apt-repository: command not found. The same happens with apt-key adv --keyserver keyserver.ubuntu.com --recv-keys, because the missing binary is the same.

To confirm this is your case, check which Debian is inside the image. On node:26-slim the answer was this:

$ docker run --rm node:26-slim sh -c \
    'cat /etc/debian_version; apt --version; ls /usr/bin/apt-key'
13.8
apt 3.0.4 (arm64)
ls: cannot access '/usr/bin/apt-key': No such file or directory

The same command on node:24-slim returned 12.15, apt 2.6.2 and a 27,972-byte /usr/bin/apt-key. I used the official images through the mirror.gcr.io/library/ mirror, which serves the same tags.

Why does it fail now if the Dockerfile has not changed?

It fails because the unsuffixed tag of your base image now points to Debian 13, and apt stopped installing apt-key before that release. The warning had been in the manual for years. The apt-key(8) page of Debian 12 says: "apt-key(8) will last be available in Debian 11 and Ubuntu 22.04". Debian 12 kept it for one more release, and the apt changelog[1] records in 2.9.17, dated 7 December 2024: "Stop installing apt-key, make it a test suite helper".

software-properties-common has a different story. The Debian package tracker[2] shows it was removed from testing on 23 October 2024 and did not get back in before trixie was released on 9 August 2025. On 25 November 2026 its migration was still blocked.

What changed for you is the tag. I walked the history of the manifests in the docker-library/official-images[3] repository and wrote down the commit where each unsuffixed tag moved from bookworm to trixie:

Image Tags that moved to trixie Commit date
debian latest 2025-08-11
php 8.2, 8.3, 8.4, latest 2025-08-11
python 3.11, 3.12, 3.13, latest 2025-08-11
postgres 14 to 17, latest 2025-08-11
ruby, httpd latest 2025-08-11
golang, buildpack-deps latest 2025-08-12
rust latest 2025-08-19
nginx latest and stable 2025-10-07 and 2025-12-23
redis 8, latest 2026-02-10
node latest, current 2026-05-06
node lts 2026-10-28

Later versions were born on trixie: python:3.14 and 3.15, php:8.5 and 8.6, postgres:18 and 19, golang:1.26 and 1.27. Node is the latest case. node:24 and node:22 are still on bookworm, but node:lts moved to Node 26 on 28 October 2026 and to Debian 13 with it. If your Dockerfile starts with FROM node:lts, its base system changed without you touching anything, as I explain in the guide to upgrading your Docker image from Node 24 to Node 26.

The fix: key in /etc/apt/keyrings and a .sources file with Signed-By

The fix replaces apt-key add with two files. The public key goes to /etc/apt/keyrings, and a .sources file in deb822 format declares the repository and names with Signed-By the key that signs it. This is the Dockerfile I built:

FROM node:26-slim
RUN apt-get update \
 && apt-get install -y --no-install-recommends ca-certificates curl \
 && curl -fsSL https://download.docker.com/linux/debian/gpg \
      -o /etc/apt/keyrings/docker.asc \
 && chmod a+r /etc/apt/keyrings/docker.asc \
 && rm -rf /var/lib/apt/lists/*
COPY <<EOF /etc/apt/sources.list.d/docker.sources
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: trixie
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
RUN apt-get update \
 && apt-get install -y --no-install-recommends docker-ce-cli \
 && rm -rf /var/lib/apt/lists/*

The first RUN downloads the key as it is, in text form, with the .asc extension. The COPY with a here-document writes the repository file, and the second RUN installs the package. It is the same structure the Docker documentation for Debian[4] uses.

The /etc/apt/keyrings directory already exists in the image. The build finished without errors and the image answered like this:

$ docker run --rm app sh -c \
    'docker --version; command -v apt-key gpg || echo "no apt-key, no gpg"'
Docker version 29.10.1, build c48360f
no apt-key, no gpg

I did not install gnupg at any step. apt has read text keys since version 1.4, and on trixie it checks them with sqv, which the image already has. The usual recipe with gpg --dearmor forces you to install gnupg: on node:26-slim that is 25 packages and 24.1 MB according to apt. I built both variants to see what each one weighs:

Image size depending on how you store the repository key MB
node:26-slim unchanged
374 MB
.asc key, no gnupg
445 MB
gnupg and gpg --dearmor
457 MB
Show the data table
ImageMB
node:26-slim unchanged374 MB
.asc key, no gnupg445 MB
gnupg and gpg --dearmor457 MB

Size shown by docker images on arm64, 25 November 2026. Both variants install docker-ce-cli 29.10.1 on node:26-slim and delete the apt lists.

The same fix works on bookworm. On node:26-bookworm-slim, with Suites: bookworm, apt 2.6.2 accepted the .asc key and the .sources file and installed the same Docker 29.10.1. You can correct the Dockerfile today and change the base later.

The other ways to declare the key that I tested on trixie

I tested four more variants on node:26-slim, with the same repository:

  • One-line format with signed-by: deb [signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian trixie stable in a .list file worked
  • Key inside the .sources file: the key block in the Signed-By field itself, with a space before each line and a dot on the empty lines, worked with no separate key file
  • Key in /etc/apt/trusted.gpg.d/docker.asc: it worked without Signed-By, but that key then counts for every repository
  • Key in /etc/apt/trusted.gpg: it did not work; that is the file apt-key add wrote to, and apt 3.0.4 did not read it

The one-line format is still accepted. The trixie sources.list(5) manual says of it: "This format is deprecated and may eventually be removed, but not before 2029".

What replaces add-apt-repository on Debian 13?

Nothing with that name: you write the .sources file yourself, which is what the tool did underneath. Each use of add-apt-repository has an equivalent, and I tested all four on node:26-slim.

To add a third-party repository, create its file as in the previous section. With the PostgreSQL Global Development Group (PGDG) repository I installed the PostgreSQL 19 client, which trixie does not carry:

curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
  -o /etc/apt/keyrings/pgdg.asc
printf '%s\n' 'Types: deb' \
  'URIs: https://apt.postgresql.org/pub/repos/apt' \
  'Suites: trixie-pgdg' 'Components: main' \
  'Signed-By: /etc/apt/keyrings/pgdg.asc' \
  > /etc/apt/sources.list.d/pgdg.sources
apt-get update
apt-get install -y --no-install-recommends postgresql-client-19

Afterwards, psql --version answered psql (PostgreSQL) 19.0 (Debian 19.0-2.pgdg13+1).

To enable contrib or non-free, which used to be add-apt-repository contrib, edit the file the image already has. After this change and an apt-get update, the unrar package from non-free had a candidate:

sed -i 's/^Components: main$/Components: main contrib non-free/' \
  /etc/apt/sources.list.d/debian.sources

For a key you used to fetch with apt-key adv --keyserver, ask the keyserver for it over HTTPS with its full fingerprint. I tested it with the R repository for Debian, the Comprehensive R Archive Network (CRAN):

KEY=95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7
curl -fsSL \
  "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x$KEY" \
  -o /etc/apt/keyrings/cran.asc

With that key and a cran.sources file with Suites: trixie-cran40/, apt-get update downloaded the index and r-base-core had a candidate.

If you prefer one command, Debian 13 has extrepo. After apt-get install extrepo, running extrepo enable docker-ce created /etc/apt/sources.list.d/extrepo_docker-ce.sources with its key in /var/lib/extrepo/keys/, and docker-ce-cli became available. It only covers the repositories in its catalogue. Ubuntu's Personal Package Archives (PPA) were never meant for Debian, and I did not test any.

Other packages that vanish in trixie and break the Dockerfile

After you fix the repository, the next apt-get install can fail on a package that changed its name. I simulated the installation of 158 package names that are common in a Dockerfile, on bookworm and on trixie: 31 install on Debian 12 and fail on Debian 13. These thirteen are the ones I checked together with their replacement:

Package on bookworm Error on trixie Replacement I tested on trixie
libgl1-mesa-glx has no installation candidate libgl1
libaio1 Unable to locate package libaio1t64
libpcre3-dev has no installation candidate libpcre2-dev
openjdk-17-jre-headless has no installation candidate openjdk-21-jre-headless
python3-distutils has no installation candidate None
libmagickwand-6.q16-6 Unable to locate package libmagickwand-7.q16-10
libncurses5, libtinfo5 Unable to locate package libncurses6, libtinfo6
libicu72 Unable to locate package libicu76
postgresql-client-15 Unable to locate package postgresql-client-17
wkhtmltopdf has no installation candidate None
libgconf-2-4 Unable to locate package None

The first one is what breaks Python projects that use OpenCV. On python:3.15-slim, the line apt-get install -y libgl1-mesa-glx libglib2.0-0 ends like this:

Package libgl1-mesa-glx is not available, but is referred to by another
package. This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libgl1-mesa-glx' has no installation candidate

With libgl1 libglib2.0-0 the installation finished fine. python3-distutils has no replacement because trixie ships Python 3.13.5, which no longer includes that module. For Java, trixie offers openjdk-21-jre-headless and openjdk-25-jre-headless.

These are the gotchas I ran into while testing the fix:

  • Key permissions: with chmod 600 on docker.asc, apt-get update failed with Failed to parse keyring "/etc/apt/keyrings/docker.asc" and Permission denied (os error 13), and then with The repository […] is not signed
  • No key: the error no longer mentions NO_PUBKEY; on trixie it is Sub-process /usr/bin/sqv returned an error code (1), error message is: Missing key 7EA0A9C3F273FCD8, which is needed to verify signature
  • python and netcat: they give has no installation candidate on trixie, but on bookworm too, so they do not come from this change

PHP extensions have their own change in that image, which I explain in the guide to pecl: not found on php:8.6.

Stopgap: pin the -bookworm tag

If you cannot touch the Dockerfile today, change only the first line to the Debian 12 variant. With FROM node:26-bookworm-slim and bookworm in the repository line, the broken Dockerfile from the start built again, with two warnings:

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d
instead (see apt-key(8)).
OK
W: https://download.docker.com/linux/debian/dists/bookworm/InRelease: Key
is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the
DEPRECATION section in apt-key(8) for details.

It is a stopgap with a date. The Debian 12 page[5] says full support ended on 11 July 2026 and that LTS remains until 30 June 2028. That LTS only covers the i386, amd64, armhf, arm64 and ppc64el architectures.

The variant does not exist for every image. On 25 November 2026, the manifests have -bookworm for node:26, python:3.15, php:8.6, golang:1.27 and postgres:19. They do not have it for nginx, httpd or redis:8.12, which only publish trixie and Alpine. If you are going to change the base anyway, the Wolfi, Alpine and distroless comparison measures the alternatives.

FAQ

Can I install apt-key on Debian 13?

No. On node:26-slim, apt-get install -y apt-key answered E: Unable to locate package apt-key, and installing gnupg does not bring it back either. The apt package stopped installing that program in version 2.9.17 and trixie ships 3.0.4. Replace each apt-key add with a key file and the Signed-By field.

Do I need gnupg to add a repository in a Dockerfile?

No, if you store the key as text with the .asc extension. apt has read it that way since version 1.4, and in my test it worked on apt 2.6.2 and on apt 3.0.4. You only need curl and ca-certificates to download it, and you save 25 packages.

Does the .sources file also work on Debian 12 and on Ubuntu?

On Debian 12 it does: I tested it on node:26-bookworm-slim with apt 2.6.2. I did not test it on Ubuntu for this guide. The Docker on Debian 13 installation uses the same format on a server instead of in an image.

Conclusion

The error does not come from your Dockerfile but from the base: the tag you use is now Debian 13, where apt-key and add-apt-repository do not exist. Download the key to /etc/apt/keyrings/name.asc, make it readable and declare the repository in a .sources file with Signed-By. Remove gnupg and software-properties-common from the package list, and review the names that change, starting with libgl1-mesa-glx. If you need time, -bookworm gives it to you until 30 June 2028 at the latest.

Sources: [1] Debian Manpages, apt-key manual on bookworm[6], [2] Debian Manpages, sources.list manual on trixie[7], [3] apt changelog on Salsa[1], [4] Debian Package Tracker, software-properties[2], [5] Debian, bookworm release information[5], [6] docker-library/official-images, official image manifests[3], [7] official-images, commit that moves node:lts to Node 26[8], [8] Docker Docs, install Docker Engine on Debian[4].

Sources

  1. apt changelog
  2. Debian package tracker
  3. docker-library/official-images
  4. Docker documentation for Debian
  5. Debian 12 page
  6. Debian Manpages, apt-key manual on bookworm
  7. Debian Manpages, sources.list manual on trixie
  8. official-images, commit that moves node:lts to Node 26