Skip to main content

Crate docker_credentials_config

Crate docker_credentials_config 

Source
Expand description

Load Docker client configuration and credentials from ~/.docker/config.json.

This crate reads the Docker CLI configuration file and resolves credentials for registries, including support for external credential helpers (credsStore, credHelpers) such as osxkeychain, secretservice, or pass.

§Usage

§Loading credentials for a specific registry

use docker_credentials_config::DockerConfig;

let config = DockerConfig::load().await?;
if let Some(creds) = config.credentials_for_registry("https://index.docker.io/v1/") {
    println!("logged in as {:?}", creds.username);
}

§Resolving credentials from an image name

use docker_credentials_config::{DockerConfig, image_registry};

let config = DockerConfig::load().await?;
let registry = image_registry("gcr.io/myproject/myimage:latest");
let creds = config.credentials_for_registry(&registry);

Structs§

DockerConfig
Parsed Docker client configuration, loaded from ~/.docker/config.json.

Enums§

Error
Errors returned by this crate.

Constants§

DOCKER_CONFIG_FILENAME
Default Docker configuration filename inside the config directory.
INDEX_NAME
Canonical name for the Docker Hub registry.

Functions§

image_registry
Extract the registry hostname from a Docker image reference.