docker-py

Manage Docker containers, images, and networks programmatically from Python code.

9|5|Updated Aug 8, 2025
One-click install
npx skills add https://github.com/AnExiledDev/CodeForge --skill docker-py
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-py
Source: https://github.com/AnExiledDev/CodeForge/tree/main/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/docker-py
Command: npx skills add https://github.com/AnExiledDev/CodeForge --skill docker-py

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Enables programmatic access to the Docker Engine API from Python applications, replacing manual CLI interactions with code-driven container management.

Core Features & Use Cases

  • Manage containers: run, start, stop, inspect, and remove
  • Control images, volumes, and networks; perform build and pull operations
  • Execute commands inside containers, capture logs, and await results
  • Handle common errors with explicit exceptions (ImageNotFound, NotFound, APIError)

Quick Start

Install the docker package, import docker, and begin managing containers with docker.from_env().

Frequently Asked Questions about docker-py

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage Docker containers from Python code instead of using the CLI?

You can manage Docker containers from Python code by using the docker SDK to control the Docker Engine API. This replaces manual CLI interactions, allowing you to programmatically run, start, stop, inspect, and remove containers within your automation workflows.

What is the best way to run commands inside a Docker container using Python?

The best way to run commands inside a Docker container using Python is through the docker SDK's exec_run method. This programmatic approach captures container logs and awaits execution results directly from your Python application.

How does Python handle Docker API errors like ImageNotFound or APIError?

Python handles Docker API errors using explicit exceptions defined in the docker SDK, such as ImageNotFound, NotFound, and APIError. You can catch these specific exceptions in your code to manage missing images or API failures gracefully.

Can I use Python to build and pull Docker images and manage networks?

Yes, you can use Python to build and pull Docker images, manage volumes, and control networks. The docker SDK provides programmatic methods to handle these operations alongside container management tasks.

Do I need the Docker CLI installed to control Docker from Python?

You need the Docker Engine running, but you do not need manual CLI interactions to control Docker from Python. By installing the docker package and calling docker.from_env(), your Python app communicates directly with the Engine API.