MCPcopy
hub / github.com/docker/docker-py

github.com/docker/docker-py @7.1.0 sqlite

repository ↗ · DeepWiki ↗ · release 7.1.0 ↗
2,116 symbols 9,093 edges 136 files 371 documented · 18%
README

Docker SDK for Python

Build Status

A Python library for the Docker Engine API. It lets you do anything the docker command does, but from within Python apps – run containers, manage containers, manage Swarms, etc.

Installation

The latest stable version is available on PyPI. Install with pip:

pip install docker

Older versions (< 6.0) required installing docker[tls] for SSL/TLS support. This is no longer necessary and is a no-op, but is supported for backwards compatibility.

Usage

Connect to Docker using the default socket or the configuration in your environment:

import docker
client = docker.from_env()

You can run containers:

>>> client.containers.run("ubuntu:latest", "echo hello world")
'hello world\n'

You can run containers in the background:

>>> client.containers.run("bfirsh/reticulate-splines", detach=True)
<Container '45e6d2de7c54'>

You can manage containers:

>>> client.containers.list()
[<Container '45e6d2de7c54'>, <Container 'db18e4f20eaa'>, ...]

>>> container = client.containers.get('45e6d2de7c54')

>>> container.attrs['Config']['Image']
"bfirsh/reticulate-splines"

>>> container.logs()
"Reticulating spline 1...\n"

>>> container.stop()

You can stream logs:

>>> for line in container.logs(stream=True):
...   print(line.strip())
Reticulating spline 2...
Reticulating spline 3...
...

You can manage images:

>>> client.images.pull('nginx')
<Image 'nginx'>

>>> client.images.list()
[<Image 'ubuntu'>, <Image 'nginx'>, ...]

Read the full documentation to see everything you can do.

Core symbols most depended-on inside this repo

create_container
called by 192
docker/api/container.py
join
called by 185
docker/models/swarm.py
start
called by 151
docker/models/containers.py
get
called by 136
docker/credentials/store.py
_url
called by 112
docker/api/client.py
from_env
called by 106
docker/client.py
create_host_config
called by 105
docker/api/container.py
make_fake_client
called by 86
tests/unit/fake_api_client.py

Shape

Method 1,638
Class 253
Function 204
Route 21

Languages

Python100%

Modules by API surface

tests/integration/api_container_test.py119 symbols
tests/unit/api_container_test.py106 symbols
tests/unit/utils_test.py89 symbols
tests/unit/api_test.py76 symbols
tests/integration/api_service_test.py76 symbols
tests/unit/dockertypes_test.py72 symbols
tests/unit/auth_test.py69 symbols
tests/unit/utils_build_test.py55 symbols
tests/unit/fake_api.py54 symbols
tests/unit/models_containers_test.py53 symbols
tests/integration/models_containers_test.py43 symbols
docker/types/services.py43 symbols

Dependencies from manifests, versioned

requests2.26.0 · 1×
urllib31.26.0 · 1×

For agents

$ claude mcp add docker-py \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact