17.3. Running Skopeo in a container using authfiles
You can use an authentication file (authfile) to specify credentials. The skopeo login command logs into the specific registry and stores the authentication token in the authfile. The advantage of using authfiles is preventing the need to repeatedly enter credentials.
When running on the same host, all container tools such as Skopeo, Buildah, and Podman share the same authfile. When running Skopeo in a container, you have to either share the authfile on the host by volume-mounting the authfile in the container, or you have to reauthenticate within the container.
Prerequisites
-
The
container-toolsmeta-package is installed.
Procedure
Inspect a remote container image using Skopeo against a locked registry:
$ podman run --rm -v $AUTHFILE:/auth.json registry.redhat.io/rhel10/skopeo inspect docker://$IMAGEThe
-v $AUTHFILE:/auth.jsonoption volume-mounts an authfile at /auth.json within the container. Skopeo can now access the authentication tokens in the authfile on the host and get secure access to the registry.
The other Skopeo commands work similarly, for example:
-
Use the
skopeo-copycommand to specify credentials on the command line for the source and destination image using the--source-credsand--dest-credsoptions. It also reads the/auth.jsonauthfile. -
If you want to specify separate authfiles for the source and destination image, use the
--source-authfileand--dest-authfileoptions and volume-mount those authfiles from the host into the container.