Registry / devops / docker-pycreds

docker-pycreds

JSON →
library0.4.0pypypi✓ verified 26d ago

docker-pycreds provides Python bindings for the Docker credentials store API. It enables programmatic interaction with platform-specific credential helpers (e.g., `docker-credential-secretservice`) to securely store and retrieve Docker authentication tokens. The current version is 0.4.0, released on November 28, 2018. Due to its last update date, it has an infrequent release cadence and appears to be in maintenance mode.

pip install docker-pycreds
INSTALL
IMPORT
SIG · DOCKER-PYCREDS
D
docker-pycreds
devopspythonv0.4.0
Install
1.6s avg
Import
973ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.632s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.536s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Store
from dockerpycreds import Store
from dockerpycreds import Store

This quickstart demonstrates how to instantiate a credential store and use it to store and list Docker credentials. It assumes a `docker-credential` helper for your platform is installed and configured. Storing credentials might trigger a system-level prompt for keyring access depending on the backend.

import dockerpycreds import os # Configure the credential store backend. Common options include: # 'secretservice' (Linux), 'osxkeychain' (macOS), 'wincred' (Windows) # If you have a custom credential helper, use its name (e.g., 'ecr-login') # Ensure the corresponding 'docker-credential-<backend>' executable is in your PATH. store_backend = os.environ.get('DOCKER_CREDS_STORE_BACKEND', 'secretservice') store = dockerpycreds.Store(store_backend) # Define credentials from environment variables for security in examples server_url = os.environ.get('DOCKER_SERVER_URL', 'https://index.docker.io/v1/') username = os.environ.get('DOCKER_USERNAME', 'testuser') secret = os.environ.get('DOCKER_SECRET', 'testpassword') print(f"Attempting to store credentials for {username} on {server_url} using '{store_backend}'...") try: store.store( server=server_url, username=username, secret=secret ) print("Credentials stored successfully. Note: This might have prompted for system keyring access.") except Exception as e: print(f"Failed to store credentials: {e}. Ensure the credential helper is correctly configured and accessible.") print("\nListing all known Docker credential servers:") try: creds_list = store.list() if creds_list: for server, user in creds_list.items(): print(f" Server: {server}, Username: {user}") else: print(" No credentials found.") except Exception as e: print(f"Failed to list credentials: {e}. Listing may require user interaction or specific backend support.") # Example of getting credentials (often requires explicit interaction with the helper) # This is commented out as it frequently requires external CLI calls or user prompts # which are hard to automate in a simple quickstart. # try: # retrieved_username, retrieved_secret = store.get(server_url) # print(f"\nRetrieved credentials for {server_url}: Username: {retrieved_username}, Secret: {'*' * len(retrieved_secret)}") # except Exception as e: # print(f"Failed to retrieve credentials: {e}. This often requires direct Docker CLI interaction or specific credential helper setup.")
Debug
Known issues
gotchaThis library acts as a Python wrapper around external `docker-credential-<helper>` executables. It requires a suitable credential helper to be installed and available in your system's PATH (e.g., `docker-credential-secretservice` for Linux). Without these executables, the library cannot function.
fix
Install the appropriate Docker credential helper for your operating system and ensure it's accessible in your system's PATH. Refer to Docker's official documentation on credential helpers.
affects: 0.1.0 - 0.4.0
deprecatedThe library has not been updated since November 2018 (version 0.4.0). While it's a dependency of the actively maintained `docker` (formerly `docker-py`) library, direct usage might encounter compatibility issues with newer Python versions (beyond 3.6) or recent changes in Docker's credential helper API.
fix
For core Docker interactions, rely on the `docker` SDK for Python which manages this dependency. If direct interaction is required, thoroughly test with your target Python and Docker environment. Be aware that issues might not be patched.
affects: <=0.4.0
gotchaThere is another Python library named `pycreds` (pypi.org/project/pycreds) which is unrelated to Docker credentials. `docker-pycreds` is specifically for integrating with Docker's credential store.
fix
Ensure you `pip install docker-pycreds` and import `dockerpycreds` to use this library. Do not confuse it with `pycreds`.
affects: All versions
gotchaOperations like `store()`, `get()`, and `delete()` often interact with the operating system's credential store (e.g., keyring, secure vault). This can lead to system-level password prompts, especially for the 'secretservice' backend on Linux, which might cause hangs in non-interactive environments.
fix
When using `docker-pycreds` in automated scripts or non-interactive environments, ensure that the chosen credential helper backend is configured for non-interactive use, or consider using environment variables for credentials where appropriate and secure.
affects: 0.1.0 - 0.4.0
Upgrade
Version history
0.4.0latest on PyPI · released Nov 29, 2018
Audit
Dependencies
sixrequiredCompatibility layer for Python 2 and 3.
docker-credential-helpersrequiredRequires a platform-specific Docker credential helper executable (e.g., docker-credential-secretservice for Linux, docker-credential-osxkeychain for macOS, or docker-credential-wincred for Windows) to be installed and available in the system's PATH. This is a crucial system-level dependency.
Agent activity
39 hits · last 30 days
node
36
Amazon
1
OpenAI (training)
1
Resources
docker-pycreds — pip install docker-pycreds · libregistry