Skip to main content

DockerConfig

Struct DockerConfig 

Source
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

Source

pub async fn load() -> Result<Self, Error>

Load the Docker configuration from the standard location.

Search order:

  1. $DOCKER_CONFIG/config.json (if DOCKER_CONFIG env var is set)
  2. ~/.docker/config.json

Returns an empty config if no file is found.

Source

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:

  1. Per-registry credential helper (credHelpers)
  2. Inline auth or identitytoken in the auths section
  3. Global credential store (credsStore)

Returns None if no credentials are found or the credential helper fails (e.g. the helper binary is not installed).

Source

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

Source§

fn clone(&self) -> DockerConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DockerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DockerConfig

Source§

fn default() -> DockerConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DockerConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,