{"id":9256,"library":"python-dxf","title":"Python DXF (Docker Registry Client)","description":"python-dxf is a Python module and command-line tool for storing and retrieving data in a Docker v2 registry. It functions as a Docker registry v2 client, enabling tasks like transferring Docker images between registries, especially useful for disconnected environments. The library creates payloads directly from the registry, which can be faster than `docker save` and `docker load`, and can compute diffs to reduce transfer size. The current version is 12.1.1 and it appears to be actively maintained.","status":"active","version":"12.1.1","language":"en","source_language":"en","source_url":"https://github.com/davedoesdev/dxf","tags":["docker","registry","container","devops","cloud"],"install":[{"cmd":"pip install python-dxf","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary class for interacting with a Docker registry.","symbol":"Dxf","correct":"from dxf import Dxf"}],"quickstart":{"code":"import os\nfrom dxf import Dxf\n\n# Configure registry connection via environment variables or direct arguments\n# DXF_HOST, DXF_USERNAME, DXF_PASSWORD, DXF_INSECURE, etc.\n\nhost = os.environ.get('DXF_HOST', 'registry.example.com')\nusername = os.environ.get('DXF_USERNAME', '')\npassword = os.environ.get('DXF_PASSWORD', '')\ninsecure = os.environ.get('DXF_INSECURE', '0') == '1'\n\ntry:\n    # Connect to the registry\n    # In a real scenario, handle credentials securely (e.g., from a vault)\n    client = Dxf(host, username=username, password=password, insecure=insecure)\n    print(f\"Connected to registry: {host}\")\n\n    # Example: List repositories (requires appropriate permissions)\n    # NOTE: Dxf API might not directly expose 'list_repositories' in all versions,\n    # this is a conceptual example based on its registry client nature.\n    # Refer to the official library documentation for exact API calls.\n    # if hasattr(client, 'list_repositories'): # Illustrative, actual method names vary\n    #     repositories = client.list_repositories()\n    #     print(f\"Repositories: {repositories}\")\n    # else:\n    #     print(\"Method to list repositories not found or not directly exposed by Dxf object.\")\n\n    # More likely usage involves specific image/layer operations, e.g.:\n    # blob_digest = client.push_blob('my-repo/my-image', 'sha256:...')\n    # manifest = client.get_manifest('my-repo/my-image', 'latest')\n    print(\"Dxf client initialized. You can now perform registry operations.\")\n\nexcept Exception as e:\n    print(f\"Failed to connect or perform operation: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `Dxf` client for a Docker registry, using environment variables for configuration. It shows the basic connection pattern. Actual registry operations (like listing repositories, pushing/pulling blobs or manifests) require specific API calls which might vary depending on the exact version and intended functionality. Ensure environment variables like `DXF_HOST`, `DXF_USERNAME`, and `DXF_PASSWORD` are set for authentication and host connection."},"warnings":[{"fix":"Be aware of this limitation and plan to generate Docker image configurations separately if `docker pull` compatibility is required. This library is primarily for raw registry interaction (blobs, manifests).","message":"The `python-dxf` library *does not* generate Docker container configurations. This means you cannot simply `docker pull` data that you store using this library directly without additional steps to create the necessary Docker image manifest and configuration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure the necessary `DXF_*` environment variables are correctly set for your target registry, or pass the corresponding arguments directly to the `Dxf` constructor if the API supports it in your version. For production, consider using a secure secrets management system.","message":"Authentication to the Docker registry heavily relies on environment variables (`DXF_HOST`, `DXF_USERNAME`, `DXF_PASSWORD`, `DXF_INSECURE`, `DXF_AUTHORIZATION`, `DXF_AUTH_HOST`). Misconfiguration or omission of these can lead to authentication failures or incorrect registry connections.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the `DXF_HOST` environment variable is set to the correct hostname or IP address of your Docker registry, or pass the correct host argument to the `Dxf` constructor.","cause":"The `DXF_HOST` environment variable is not set or points to an invalid/unreachable Docker registry host.","error":"Failed to connect: 'No such host is known'"},{"fix":"Set `DXF_USERNAME` and `DXF_PASSWORD` environment variables, or `DXF_AUTHORIZATION` for a raw token. Verify that the credentials are correct and have the necessary permissions for the desired operations (e.g., pull, push).","cause":"Incorrect or missing authentication credentials (username, password, or authorization token) for the Docker registry.","error":"Failed to connect or perform operation: Authentication Required"}]}