Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Container build fails: potentially insufficient UIDs or GIDs in the user namespace

Errorpotentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/shadow)

Short answer

Rootless builds map the file owners inside an image to subordinate IDs your user owns. If your user has no range in /etc/subuid and /etc/subgid, or newuidmap is missing, the mapping fails. Add a range of 65,536 IDs, make sure newuidmap exists, then run podman system migrate.

  • Applies to Podman 5, Buildah 1.3x, Rocky Linux 9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the ID mapping your user gets. A single line such as 0 1000 1 means no subordinate range is in effect.

    podman unshare cat /proc/self/uid_map
  2. 2Match what you see, then jump to its fix

    1. 1uid_map shows only one line, or the entries in /etc/subuid and /etc/subgid are missing or commented outNo subordinate ID range for your userFix
    2. 2The ranges exist but the mapping still fails, or the command is not foundnewuidmap and newgidmap are missing or not allowed to set IDsFix

What does the error look like?

  • potentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/shadow)
  • error creating libpod runtime: there might not be enough IDs available in the namespace

Cause 1 of 2

No subordinate ID range for your user

1Check

Each line in /etc/subuid and /etc/subgid has the form user:start:count. Look for your user name in both files.

grep "^$(whoami):" /etc/subuid /etc/subgid

2Fix

Add a range of 65,536 IDs for your user, then let Podman reload the mapping. Choose a start that overlaps no other user.

sudo usermod --add-subuids 200000-265535 --add-subgids 200000-265535 $(whoami)
podman system migrate

3Verify

The map now shows a second range.

podman unshare cat /proc/self/uid_map

Confirmed by github.com

Did this fix it?

Cause 2 of 2

newuidmap and newgidmap are missing or not allowed to set IDs

1Check

Rootless mode needs the newuidmap and newgidmap programs to apply subordinate IDs.

command -v newuidmap newgidmap
ls -l /usr/bin/newuidmap /usr/bin/newgidmap

2Fix

Install the package that provides them (uidmap on Debian and Ubuntu, per the Docker rootless docs). If they exist but the permissions were changed, restore the packaged ones by reinstalling that package.

sudo apt-get install uidmap

3Verify

Both commands are found, then retry the build.

command -v newuidmap newgidmap
podman build -t test .

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Create users with useradd or adduser on current distributions so the subuid and subgid lines are added for them.
  • Run podman system migrate after any manual change to /etc/subuid or /etc/subgid.
  • Keep ranges of at least 65,536 IDs per user, as the Docker rootless docs advise.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.