singularity icon indicating copy to clipboard operation
singularity copied to clipboard

pull from password-protected docker-repo does not work

Open ps-account opened this issue 8 years ago • 17 comments

Version of Singularity:

2.4.2 / any

Expected behavior

sudo singularity pull docker://my.passwordprotected.dockerrepo/reponame/imagename:tag pulls and then builds

Actual behavior

ERROR Error getting token for repository ....

The issue seems to be fully related to https://github.com/moby/moby/issues/25169 Any constellation where a "docker login" fails (e.g. as sudo, headless) will currently fail because its depency on gnome-keyring. An alternative system is planned (since 2016!!) according to https://github.com/moby/moby/issues/25169

Steps to reproduce behavior

WORKAROUND docker pull from a password-protected as user from a graphical desktop (not headless) from there e.g. or upload to your own local open repo and pull it again via singularity

ps-account avatar Feb 14 '18 12:02 ps-account

You should export DOCKER_USERNAME and DOCKER_PASSWORD to the environment first.

vsoch avatar Feb 14 '18 13:02 vsoch

Thanks for the pointer! But this doesn't change anything for me, also didn't find a mention of these environmental variables before.

ps-account avatar Feb 14 '18 13:02 ps-account

http://singularity.lbl.gov/docs-docker

vsoch avatar Feb 14 '18 13:02 vsoch

Check your capitalization and spelling, and please share the full debug output and your steps so we can help.

vsoch avatar Feb 14 '18 13:02 vsoch

Hi @rdwrt, can you try this:

sudo SINGULARITY_DOCKER_USERNAME=user SINGULARITY_DOCKER_PASSWORD=password singularity build imagename.simg docker://my.passwordprotected.dockerrepo/reponame/imagename:tag

The environment variables likely won't be preserved across your sudo call, so you can specify them ahead of the command, or you can export them inside a session where you are root already.

And if you have other errors, can you try running with debug, which needs the -d option, and let us know what you get?

sudo SINGULARITY_DOCKER_USERNAME=user SINGULARITY_DOCKER_PASSWORD=password singularity -d build imagename.simg docker://my.passwordprotected.dockerrepo/reponame/imagename:tag

Thanks!

dtrudg avatar Feb 14 '18 15:02 dtrudg

Ok thanks all, it works with sudo -E singularity build ...

Now I'll look for a way to not having to put plain text password into an environment variable, but that's a different story :) no issue here anymore.

ps-account avatar Feb 15 '18 12:02 ps-account

Hello @vsoch

I'm having some difficulty authenticating when pulling Docker images from Artifactory using Singularity:

singularity -d pull docker:///artifactory.company.com/dir1/dir2/dir3/dir4/latest DEBUG [U=12487,P=1872] NewBundle() Created temporary directory for bundle /tmp/sbuild-012588319 INFO [U=12487,P=1872] Full() Starting build... DEBUG [U=12487,P=1872] Get() Reference: <> FATAL [U=12487,P=1872] PullOciImage() Unable to pull docker://<>/latest: conveyor failed to get: Error reading manifest latest in docker.io/<>/latest: errors: denied: requested access to the resource is denied unauthorized: authentication required

I've tried setting the env vars as you mention above (both as exported vars and prior to the command being executed), but this doesn't resolve the issue.

Is there a Singularity equivalent to docker login, or can we specify credentials in another manner (token file)?

whatsondoc avatar Jan 31 '19 08:01 whatsondoc

I'm not the best to answer this question as the backend is different (and I wouldn't be surprised if functionality is different) but from this conversation https://github.com/sylabs/singularity/issues/693#issuecomment-385194505 it seems that support for a docker config might be possible. I'd wait to hear from sylabs on this issue, thanks!

vsoch avatar Jan 31 '19 10:01 vsoch

Heya @whatsondoc what version of Singularity are you using? This functionality was un-intentionally omitted from 3.0.0 and 3.0.1, but was added back in 3.0.2 and works in 3.0.3. Check out the --docker-login option. And you can also use the $SINGULARITY_DOCKER_USERNAME and $SINGULARITY_DOCKER_PASSWORD env vars if you don't mind saving your password in plain text on your system.

GodloveD avatar Jan 31 '19 15:01 GodloveD

Thanks @GodloveD !

vsoch avatar Jan 31 '19 15:01 vsoch

Hello @GodloveD

We're on: singularity version 3.0.1-138.g963705a

So looks like we need to update - thanks!

whatsondoc avatar Feb 01 '19 21:02 whatsondoc

Hello @GodloveD

Is there any part of the documentation that covers this, with some usage scenarios?

We are still struggling to use Singularity to interact with any of our containers stored in Artifactory.

Singularity version has been updated: singularity version 3.0.3-464.g6272a2a

Repeatedly being told that either:

FATAL [U=12487,P=4615] PullLibraryImage() Download did not succeed: 0

Or:

FATAL [U=12487,P=25835] PullLibraryImage() The requested image was not found in the library

It does look as though Singularity may be injecting "v1/imagefile/" into the URI:

Per line 44: https://github.com/sylabs/singularity/blob/55c4d4d528b7d225c79251ee7a2c0eebe1da849b/pkg/client/library/pull.go#L44

**url := libraryURL + "/v1/imagefile/" + libraryRef**

Is there any further debug information that would be useful to diagnose this?

whatsondoc avatar Feb 07 '19 09:02 whatsondoc

@ikaneshiro ping!

jscook2345 avatar Feb 07 '19 18:02 jscook2345

Hey @whatsondoc! Are you using docker://... or library://... to pull your image? That error message looks like its trying to pull the image from the sylabs cloud library and not from a docker registry.

Also you can get debug info by running singularity with the -d flag. E.g. singularity -d pull ....

ikaneshiro avatar Feb 07 '19 19:02 ikaneshiro

Both, actually, until we realised that library:// seems to want to add that extra string.

After re-focusing on using docker://, the errors have shifted slightly from what we were seeing before and were most recently relating to the manifest (getting onto the right track). Alas, we now have Singularity interacting & authenticating properly with the docker repo and commands are working 👍

The command syntax, should others be looking at the same thing:

$ singularity pull --docker-login docker://artifactory.<company_domain>:/path/to/docker/container:version

We realised that you do not include the base directory in the tree in the command path (i.e. the first part of the path when looking at it through Artifactory).

whatsondoc avatar Feb 09 '19 00:02 whatsondoc

The authentication piece is interesting, though. @GodloveD provided some useful context previously about using interactive --docker-login or env vars, but what about using other methods, e.g. an API key to Artifactory?

This is probably something more development-related, and perhaps @vsoch has had a chance to look at the options for interop? Along with her 50million other tasks... 😆

If we should shift this particular topic elsewhere, give an appropriate steer :-)

whatsondoc avatar Feb 09 '19 01:02 whatsondoc

Functionality for managing docker credentials has been added in https://github.com/hpcng/singularity/pull/5593 that provides a way to interactively configure token based login etc, and will be available in 3.7.

dtrudg avatar Oct 16 '20 15:10 dtrudg