pub struct DockerConfig {
pub auths: HashMap<String, DockerCredentials>,
pub creds_store: Option<String>,
pub cred_helpers: HashMap<String, String>,
}Expand description
Parsed Docker client configuration, loaded from ~/.docker/config.json.
Contains inline credentials and references to external credential helpers.
Use DockerConfig::credentials_for_registry to resolve credentials for a
specific registry, or DockerConfig::all_credentials to collect credentials
for every known registry.
Fields§
§auths: HashMap<String, DockerCredentials>Inline credentials from the auths section of config.json, keyed
by registry URL or hostname.
creds_store: Option<String>Global credential store helper name (e.g. "osxkeychain").
cred_helpers: HashMap<String, String>Per-registry credential helpers, keyed by registry hostname.
Implementations§
Source§impl DockerConfig
impl DockerConfig
Sourcepub async fn load() -> Result<Self, Error>
pub async fn load() -> Result<Self, Error>
Load the Docker configuration from the standard location.
Search order:
$DOCKER_CONFIG/config.json(ifDOCKER_CONFIGenv var is set)~/.docker/config.json
Returns an empty config if no file is found.
Sourcepub fn credentials_for_registry(
&self,
registry: &str,
) -> Option<DockerCredentials>
pub fn credentials_for_registry( &self, registry: &str, ) -> Option<DockerCredentials>
Resolve credentials for the given registry, including via external
credential helpers (credsStore / credHelpers).
registry may be a hostname (docker.io, gcr.io) or a full URL
(https://index.docker.io/v1/). The lookup order is:
- Per-registry credential helper (
credHelpers) - Inline
authoridentitytokenin theauthssection - Global credential store (
credsStore)
Returns None if no credentials are found or the credential helper
fails (e.g. the helper binary is not installed).
Sourcepub fn all_credentials(&self) -> HashMap<String, DockerCredentials>
pub fn all_credentials(&self) -> HashMap<String, DockerCredentials>
Retrieve credentials for every registry that appears in the auths
or credHelpers sections of the config file.
Suitable for populating the X-Registry-Config header used by
multi-registry operations such as Docker::build_image.
Each registry is resolved via credentials_for_registry,
so credential helpers are invoked as needed. Registries whose helper
fails or returns no credentials are silently omitted.
Trait Implementations§
Source§impl Clone for DockerConfig
impl Clone for DockerConfig
Source§fn clone(&self) -> DockerConfig
fn clone(&self) -> DockerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more