Skip to content

fix: detect userns-remap and set correct containerd namespace#65

Open
VedantMadane wants to merge 1 commit intopsviderski:mainfrom
VedantMadane:fix/userns-remap-namespace
Open

fix: detect userns-remap and set correct containerd namespace#65
VedantMadane wants to merge 1 commit intopsviderski:mainfrom
VedantMadane:fix/userns-remap-namespace

Conversation

@VedantMadane
Copy link
Copy Markdown

Fixes #50

When Docker is configured with userns-remap, it uses a containerd namespace like moby-100000.100000 instead of the default moby. Previously, docker-pussh always started unregistry with the default moby namespace, so pushed images were invisible to docker images on the remote host.

What this does

  1. Adds a detect_containerd_namespace function that runs docker info --format '{{.DockerRootDir}}' on the remote host
  2. If the Docker Root Dir ends with a UID.GID component (e.g. /var/lib/docker/100000.100000), derives the containerd namespace as moby-100000.100000
  3. Passes -e UNREGISTRY_CONTAINERD_NAMESPACE to the unregistry container
  4. Adds UNREGISTRY_CONTAINERD_NAMESPACE to the help/usage text

The detection uses a ^[0-9]+\.[0-9]+$ regex on the basename rather than just checking != docker, to avoid false positives on non-standard Docker Root Dirs (e.g. Snap installations at /var/snap/docker/common/var-lib-docker).

Users can still override the namespace explicitly via the UNREGISTRY_CONTAINERD_NAMESPACE environment variable.

How I tested

Verified the logic against the scenarios from your root cause analysis:

  • /var/lib/docker -> basename docker -> no match -> namespace stays moby
  • /var/lib/docker/100000.100000 -> basename 100000.100000 -> matches ^[0-9]+\.[0-9]+$ -> namespace becomes moby-100000.100000

When Docker is configured with userns-remap, it uses a containerd
namespace like `moby-100000.100000` instead of the default `moby`.
Unregistry was always pushing to `moby`, so pushed images were
invisible to Docker.

Detect this by checking Docker Root Dir on the remote host. If it
ends with a UID.GID component, derive the namespace and pass it
via UNREGISTRY_CONTAINERD_NAMESPACE.

Fixes psviderski#50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] userns-remap prevents images from being seen. silently fails.

1 participant