Class DockerCredentialHelper
The credential helpers are platform-specific ways of storing and retrieving registry auth information. Docker ships with OS-specific implementations, such as osxkeychain and wincred, as well as others. But they also allow third parties to implement their own credential helpers; for instance, Google (https://github.com/GoogleCloudPlatform/docker-credential-gcr) and Amazon (https://github.com/awslabs/amazon-ecr-credential-helper) have implementations for their cloud registries.
The main interface to this class is in four static methods, which perform the four
operations of a credential helper: get(String, String), list(String),
store(String, DockerCredentialHelperAuth), and erase(String, String).
They all take the name of the credential helper as an argument; this value is usually read
as the credsStore or a credsHelper from a docker config file (see DockerConfig).
The static methods all pass their operations down to a DockerCredentialHelper.CredentialHelperDelegate
instance. By default this instance executes a command on the system. However, the delegate
is modifiable with setCredentialHelperDelegate(CredentialHelperDelegate) and
restoreSystemCredentialHelperDelegate() to facilitate testing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intErase an auth value from a credsStore matching a registry.static DockerCredentialHelperAuthGet an auth value from a credsStore for a registry.Lists credentials stored in the credsStore.static intstore(String credsStore, DockerCredentialHelperAuth auth) Store an auth value in the credsStore.
-
Constructor Details
-
DockerCredentialHelper
public DockerCredentialHelper()
-
-
Method Details
-
store
public static int store(String credsStore, DockerCredentialHelperAuth auth) throws IOException, InterruptedException Store an auth value in the credsStore.- Parameters:
credsStore- Name of the docker credential helperauth- Auth object to store- Returns:
- Exit code of the process
- Throws:
IOException- When we cannot read from the credential helperInterruptedException- When writing to the credential helper is interrupted
-
erase
public static int erase(String credsStore, String registry) throws IOException, InterruptedException Erase an auth value from a credsStore matching a registry.- Parameters:
credsStore- Name of the docker credential helperregistry- The registry for which you want to erase the auth- Returns:
- Exit code of the process
- Throws:
IOException- When we cannot read from the credential helperInterruptedException- When writing to the credential helper is interrupted
-
get
Get an auth value from a credsStore for a registry.- Parameters:
credsStore- Name of the docker credential helperregistry- The registry for which you want to auth- Returns:
- A
DockerCredentialHelperAuthauth object - Throws:
IOException- When we cannot read from the credential helper
-
list
Lists credentials stored in the credsStore.- Parameters:
credsStore- Name of the docker credential helper- Returns:
- Map of registries to auth identifiers. (For instance, usernames for which you have signed in.)
- Throws:
IOException- When we cannot read from the credential helper
-