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(®istry);Structs§
- Docker
Config - 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.