Skip to main content

A command-line tool for managing Docker containers, volumes, images, and secrets

Project description

Dkrutil

Dkrutil is a command-line tool that provides utility functions for managing Docker containers, volumes, images, and secrets.
It simplifies common tasks like listing running containers, backing up and restoring volumes, retrieving Docker image tags from Docker Hub, and securely managing secrets via Docker volumes.

Installation

You can install dkrutil directly from PyPI:

pip install dkrutil

For isolated environments and ease of management, you can use pipx:

pipx install dkrutil

Or install it using uv for development:

uv pip install dkrutil

[!WARNING] Some dkrutil commands (e.g., volume backups and secrets management) require root privileges.
If you installed dkrutil in a user-local directory (e.g., ~/.local/bin via pip or pipx), make sure the dkrutil binary is accessible to root.
For this add this alias to your shell configuration (e.g., ~/.bashrc or ~/.zshrc):

alias dkrutil='sudo -E $(echo ~/.local/bin/dkrutil)'

This ensures dkrutil can be used in scripts or commands requiring sudo.

Usage

Dkrutil provides the dkrutil command with various subcommands.

Containers

List running containers

dkrutil container ps

Options:

  • -a, --all → Show all containers, including stopped ones.

Volumes

Backup Docker volumes

dkrutil volume backup -d /path/to/backup

Options:

  • -d, --backup-directory → Directory where the volumes will be backed up.
  • -i, --include → Regex pattern to include specific volumes (can be repeated).
  • -I, --ignore → Regex pattern to ignore specific volumes (can be repeated).
  • -v, --verbose → Show skipped volumes in real time.

Restore Docker volumes

dkrutil volume restore -d /path/to/backup

Options:

  • -d, --backup-directory → Directory containing the backup files.

Images

Retrieve all tags of an image

dkrutil image tags alpine

Options:

  • -d, --digest → Filter tags by a specific SHA256 digest.
  • -t, --tag → Retrieve the digest of a specific tag.

Secrets

Create a secret stored in a Docker volume

dkrutil secret create <name> [FILE|-] [-p]

This command stores a secret securely inside a Docker named volume.

  • If FILE is omitted or set to -, the content is read from standard input.
  • A file named <name> will be created inside the volume <name> with the secret content.
  • If the volume already exists, the command will fail (no overwrite).
  • Use -p to force an interactive masked prompt.

Examples:

# From a file
dkrutil secret create db_password ./my-password.txt

# From stdin
echo "supersecret" | dkrutil secret create db_password


# Prompt
dkrutil secret create db_password -p

Configuration

Dkrutil uses the docker Python library to interact with the Docker API. Ensure Docker is installed and running before using this tool.

Development

Clone the repository:

git clone https://github.com/emerick-biron/dkrutil.git
cd dkrutil

Install dependencies with uv:

uv pip install -e .

Run the tool locally:

dkrutil --help

Build the package:

uv build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dkrutil-1.0.6.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dkrutil-1.0.6-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file dkrutil-1.0.6.tar.gz.

File metadata

  • Download URL: dkrutil-1.0.6.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dkrutil-1.0.6.tar.gz
Algorithm Hash digest
SHA256 1ed3482e089506ea7964c37394262eb63f2e9d388c1bda916f7e566eb53fe2a1
MD5 32bd00a3d6741aaf2e3154bdba6f4aba
BLAKE2b-256 eba1cc25f4579ad92cefe3a2e78a4c7c717cb9ea42db25f1bf3373fc113a47b7

See more details on using hashes here.

File details

Details for the file dkrutil-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: dkrutil-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dkrutil-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 da9bbcf2c1b409b8c0bc10d560026423d3ba5d3b8e8b81d2ac0fa10d3aab1d7a
MD5 f63328695e671f6887005f7b146fd20c
BLAKE2b-256 906e97fed4553ad34563c4b36b4748047a84a735fcf811a72396953586de5d3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page