#docker #credentials

docker_credential

Reads a user's docker credentials from config

11 stable releases

new 1.3.2 May 4, 2025
1.3.1 Mar 13, 2024
1.2.3 Feb 27, 2024
1.2.1 Nov 23, 2023
1.0.1 Apr 16, 2019

#112 in Authentication

Download history 49475/week @ 2025-01-14 48039/week @ 2025-01-21 51184/week @ 2025-01-28 60702/week @ 2025-02-04 55296/week @ 2025-02-11 61705/week @ 2025-02-18 60874/week @ 2025-02-25 61705/week @ 2025-03-04 70402/week @ 2025-03-11 73016/week @ 2025-03-18 70162/week @ 2025-03-25 72665/week @ 2025-04-01 78088/week @ 2025-04-08 69183/week @ 2025-04-15 72307/week @ 2025-04-22 63998/week @ 2025-04-29

296,424 downloads per month
Used in 179 crates (15 directly)

MIT/Apache

21KB
410 lines

docker_credential

Latest version Documentation

A Rust library for reading a user's Docker or Podman credentials from config.

Parses a docker config.json either at the location specified by the $DOCKER_CONFIG environment variable or in $HOME/.docker. If credential helpers or a credential store is configured these will be contacted to retrieve the requested credential.

Usage

Add the following to your cargo.toml:

[dependencies]
docker_credential = "1.0.1"

Then invoke from within your along the lines of:

use docker_credential;
use docker_credential::DockerCredential;

let credential = docker_credential::get_credential("https://index.docker.io/v1/").expect("Unable to retrieve credential");

match credential {
  DockerCredential::IdentityToken(token) => println!("Identity token: {}", token),
  DockerCredential::UsernamePassword(user_name, password) => println!("Username: {}, Password: {}", user_name, password),
};

Dependencies

~0.8–1.7MB
~37K SLoC