Skip to content

olex-green/docker_secrets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Secrets

Crates.io Documentation License

A Rust library to easily access Docker secrets.

Docker secrets are mounted into the container at /run/secrets. This library provides a simple interface to read them.

Installation

Add this to your Cargo.toml:

[dependencies]
docker_secrets = "0.2.0"

Usage

Get all secrets

Returns a list of secret names found in /run/secrets.

use docker_secrets::get_list;

fn main() {
    match get_list() {
        Ok(secrets) => {
            for secret in secrets {
                println!("Found secret: {}", secret);
            }
        }
        Err(e) => eprintln!("Error listing secrets: {}", e),
    }
}

Get a specific secret

Reads the content of a specific secret.

use docker_secrets::get;

fn main() {
    match get("my_secret") {
        Ok(secret_value) => println!("Secret value: {}", secret_value),
        Err(e) => eprintln!("Error reading secret: {}", e),
    }
}

Configuration

By default, the library looks for secrets in /run/secrets. You can override this path by setting the DOCKER_SECRETS_DIR environment variable. This is useful for local development and testing.

export DOCKER_SECRETS_DIR=./my_local_secrets
cargo run

License

This project is licensed under either of

at your option.

About

Returns Docker secrets in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages