Maaz Zindani

Loading the index…

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

Rootless docker pull stops with lchown: invalid argument

Your error

docker: failed to register layer: Error processing tar file(exit status 1): lchown <FILE>: invalid argument3 more lines it can show

Fix it fast

Most common cause, 1 of 3

Your user has no subordinate ID range, or one that is too short

Give the account one block of 65,536 IDs in both files with usermod.

Fix
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "$(whoami)"
systemctl --user restart docker.service
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

failed to register layer ... lchown <file>: invalid argument appears when rootless Docker cannot map a file owner from the image, because /etc/subuid or /etc/subgid gives your user too few subordinate IDs. Add a range of at least 65,536 (wider if the error names a higher UID) and restart the user daemon. Docker Engine 29 rootless mode.

  • Applies to Docker Engine 29.10 in rootless mode, containerd image store and legacy overlay2, shadow-utils usermod
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Confirm which daemon you talk to and read your subordinate ID lines. A rootless daemon lists rootless under Security Options. The last number on your line in /etc/subuid and in /etc/subgid is how many IDs your user owns.

Run this first
docker info | grep -iE "rootless|Docker Root Dir"
grep "^$(whoami):" /etc/subuid /etc/subgid

Then find the line you see in this list and open its fix:

  1. 1Your user has no subordinate ID range, or one that is too shortgrep prints nothing for one of the two files, or the count at the end of the line is well under 65536
  2. 2The image owns files with a UID larger than your rangeYour range is already 65536, and the newer message names the file with a large number after for UID
  3. 3The rootless data directory sits on NFSThe message ends in operation not permitted rather than invalid argument, and the home folder is a network mount

What does the error look like?

  • docker: failed to register layer: Error processing tar file(exit status 1): lchown <FILE>: invalid argument
  • failed to register layer: ApplyLayer exit status 1 stdout: stderr: lchown /usr/local/bin/docker-credential-gcr: invalid argument
  • failed to Lchown "<path>" for UID <uid>, GID <gid>: lchown <path>: invalid argument (Hint: try increasing the number of subordinate IDs in /etc/subuid and /etc/subgid)
  • docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: lchown <FILE>: operation not permitted

Cause 1 of 3

Your user has no subordinate ID range, or one that is too short

You seegrep prints nothing for one of the two files, or the count at the end of the line is well under 65536

Check

A rootless pull that ends in lchown ... invalid argument means the kernel had no host ID for a file owner in the layer, since /etc/subuid or /etc/subgid lists too few entries for your login. Docker's rootless prerequisites ask for at least 65,536 subordinate IDs in both files.

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

Fix

Give the account one block of 65,536 IDs in both files with usermod. Choose a start number that no other line in either file already covers. Then restart the user's Docker service so the daemon starts again with the new ranges.

Fix
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "$(whoami)"
systemctl --user restart docker.service

Verify

Both files now show a line for your user ending in 65536, and the pull that failed runs to the end.

Verify
docker pull <image-that-failed>

Confirmed by docs.docker.com

Did this fix it?

Cause 2 of 3

The image owns files with a UID larger than your range

You seeYour range is already 65536, and the newer message names the file with a large number after for UID

Check

Docker notes that the number of IDs an image needs varies, and 65,536 covers most images but not every one. In rootless mode a container UID n is placed at subuid + (n - 1) on the host, so an owner number above your count has nowhere to land.

Check
docker pull <image-that-failed> 2>&1 | grep -o 'for UID [0-9]*, GID [0-9]*'

Fix

Swap the old block for a wider one whose size is larger than the UID in the error, again without overlapping any other line. With both delete and add flags, usermod removes the old ranges before it adds the new one.

Fix
sudo usermod --del-subuids 100000-165535 --del-subgids 100000-165535 \
  --add-subuids 100000-1199999 --add-subgids 100000-1199999 "$(whoami)"
systemctl --user restart docker.service

Verify

grep shows the larger count, and the pull gets past the file that was named.

Verify
grep "^$(whoami):" /etc/subuid /etc/subgid && docker pull <image-that-failed>

Confirmed by docs.docker.com

Did this fix it?

Cause 3 of 3

The rootless data directory sits on NFS

You seeThe message ends in operation not permitted rather than invalid argument, and the home folder is a network mount

Check

Docker's troubleshooting page ties lchown ... operation not permitted mostly to ~/.local/share/docker living on NFS, where the server refuses the ownership change. More subordinate IDs do not help there.

Check
findmnt -T ~/.local/share/docker -o TARGET,FSTYPE

Fix

Point the rootless daemon at a local disk. Set data-root in the daemon.json under your own config folder, using a directory on local storage that your user owns, then restart the service.

Fix
mkdir -p ~/.config/docker
echo '{"data-root":"/local/disk/docker-data"}' > ~/.config/docker/daemon.json
systemctl --user restart docker.service

Verify

docker info reports the local path as Docker Root Dir and the pull completes.

Verify
docker info | grep "Docker Root Dir"

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Add subuid and subgid lines in the same provisioning step that creates the account that will run rootless Docker.
  • Set up each new host with dockerd-rootless-setuptool.sh install, which shows help when a prerequisite such as the ID ranges or newuidmap is missing.
  • Keep ~/.local/share/docker on a local filesystem when home folders are mounted over the network.

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?

Projects of mine on the same stack: TaxiDex, Dispatch Pro.

Next step

Want this handled for good?

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