Container build fails: potentially insufficient UIDs or GIDs in the user namespace
potentially 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.
Fix it fast
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_map2Match what you see, then jump to its fix
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/subgid2Fix
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 migrate3Verify
The map now shows a second range.
podman unshare cat /proc/self/uid_mapConfirmed by github.com
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/newgidmap2Fix
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 uidmap3Verify
Both commands are found, then retry the build.
command -v newuidmap newgidmap
podman build -t test .Confirmed by docs.docker.com
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix