How to perform podman login inside a docker container?

Viewed 785

I am trying to use podman inside a docker container, with no intention to run containers. podman will be used only for login, pull and push.

I am using python:3.7-bullseye docker image, and install the following packages:

RUN apt-get -y install runc
RUN apt-get -y install podman

Post install, podman is working and accessible:

root@992b0476dcf2:~# podman ps
CONTAINER ID  IMAGE   COMMAND  CREATED  STATUS  PORTS   NAMES
root@992b0476dcf2:~# podman version
Version:      3.0.1
API Version:  3.0.0
Go Version:   go1.15.9
Built:        Thu Jan  1 00:00:00 1970
OS/Arch:      linux/amd64

When I try to perform a podman login, I get errored as below:

root@992b0476dcf2:~# podman login my-special-registry:8080
Username: my-special-user
Password:
Error: error authenticating creds for "my-special-registry:8080": error creating new docker client: readdirent: not a directory

Could someone please help in explaining what is the path being referenced here which is not a directory?

2 Answers

A podman login to a private registry as the root user records the authentication under /run/containers/0/auth.json by default. It will write to ${XDG_RUNTIME_DIR}/containers/auth.json if the variable is set. Verify that the /run/containers path exists, is a directory and you have permission to write to it from within the container. Then do the same for ${XDG_RUNTIME_DIR}/containers if it exists.

My guess is a bind mount of a file on somewhere in one of the paths above is putting a file where podman is expecting a directory to be. This is preventing the application from writing out the auth.json file under that path.

You can also explicitly override the auth file path using export REGISTRY_AUTH_FILE=<path>. Test a login after setting this to a known writable value.

touch /tmp/auth.json
export REGISTRY_AUTH_FILE=/tmp/auth.json
podman login my-special-registry:8080

The error message was a bit misleading. After spending a few hours on this, figured out the issue was because of a badly formatted ca-certificate which I placed on the /etc/containers path.

It may help to add --log-level=debug to pinpoint issues related to podman.

Related