# docker

> A Python library for the Docker Engine API.

- **URL**: https://www.freshcrate.ai/projects/docker
- **Author**: pypi
- **Category**: Frameworks
- **Latest version**: `7.1.0` (2026-04-21)
- **License**: Unknown
- **Source**: https://github.com/docker/docker-py
- **Homepage**: https://pypi.org/project/docker/
- **Language**: Python
- **GitHub**: 7,174 stars, 1,720 forks
- **Registry**: pypi (`docker`)
- **Tags**: `pypi`

## Description

# Docker SDK for Python

[![Build Status](https://github.com/docker/docker-py/actions/workflows/ci.yml/badge.svg)](https://github.com/docker/docker-py/actions/workflows/ci.yml)

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](https://pypi.python.org/pypi/docker/). 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:

```python
import docker
client = docker.from_env()
```

You can run containers:

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

You can run containers in the background:

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

You can manage containers:

```python
>>> 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:

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

You can manage images:

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

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

[Read the full documentation](https://docker-py.readthedocs.io) to see everything you can do.

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `7.1.0` | 2026-04-21 | Low | Imported from PyPI (7.1.0) |
| `7.0.0` | 2023-12-08 | Low | ## Upgrade Notes (from 6.x) ⚠️  - Removed SSL version (`ssl_version`) and explicit hostname check (`assert_hostname`) options (#3185)   - `assert_hostname` has not been used since Python 3.6 and was removed in 3.12   - Python 3.7+ supports TLSv1.3 by default - Websocket support is no longer included by default (#3123)   - Use `pip install docker[websockets]` to include `websocket-client` dependency   - By default, `docker-py` hijacks the TCP connection and does not use Websockets   - Webs |
| `7.0.0b3` | 2023-12-05 | Low | **ℹ️  See 7.0.0b2 for full release notes**  ## Upgrade Notes (from 6.x) ⚠️  - Removed SSL version (`ssl_version`) and explicit hostname check (`assert_hostname`) options (#3185)   - `assert_hostname` has not been used since Python 3.6 and was removed in 3.12   - Python 3.7+ supports TLSv1.3 by default - Websocket support is no longer included by default (#3123)   - Use `pip install docker[websockets]` to include `websocket-client` dependency   - By default, `docker-py` hijacks the TCP co |
| `7.0.0b2` | 2023-11-27 | Low | ℹ️  **This is identical to `7.0.0b1`, which was not correctly released due to a CI pipeline issue.**  ## Upgrade Notes ⚠️  - Removed SSL version (`ssl_version`) and explicit hostname check (`assert_hostname`) options (#3185)   - `assert_hostname` has not been used since Python 3.6 and was removed in 3.12   - Python 3.7+ supports TLSv1.3 by default - Websocket support is no longer included by default (#3123)   - Use `pip install docker[websockets]` to include `websocket-client` dependency |
| `7.0.0b1` | 2023-11-21 | Low | ## Upgrade Notes ⚠️  - Removed SSL version (`ssl_version`) and explicit hostname check (`assert_hostname`) options (#3185)   - `assert_hostname` has not been used since Python 3.6 and was removed in 3.12   - Python 3.7+ supports TLSv1.3 by default - Websocket support is no longer included by default (#3123)   - Use `pip install docker[websockets]` to include `websocket-client` dependency   - By default, `docker-py` hijacks the TCP connection and does not use Websockets   - Websocket clien |
| `6.1.3` | 2023-06-01 | Low | ## 🐛 Bugfixes * Fix eventlet compatibility (#3132)  ## What's Changed * fix: eventlet compatibility by @tito in https://github.com/docker/docker-py/pull/3132  ## New Contributors * @tito made their first contribution in https://github.com/docker/docker-py/pull/3132  **Full Changelog**: https://github.com/docker/docker-py/compare/6.1.2...6.1.3 |
| `6.1.2` | 2023-05-11 | Low | ## 🐛 Bugfixes * Fix for socket timeouts on long `docker exec` calls (#3125) * Respect `timeout` param on Windows (#3112)  ## Full Changelog * Use windows api to honour timeouts (fixes #3111) by @ImogenBits in https://github.com/docker/docker-py/pull/3112 * Avoid socket timeouts when executing commands by @loicleyendecker in https://github.com/docker/docker-py/pull/3125 * docs: update changelog by @milas in https://github.com/docker/docker-py/pull/3127  ## New Contributors * @ImogenBit |
| `6.1.1` | 2023-05-08 | Low | ## ℹ️ Upgrade Notes (6.1.x) - Errors are no longer returned during client initialization if the credential helper cannot be found. A warning will be emitted instead, and an error is returned if the credential helper is used.  ## 🐛 Bugfixes - Fix `containers.stats()` hanging with `stream=True` - Correct return type in docs for `containers.diff()` method  ## What's Changed * api: update return type of `diff` method by @john-b-yang in https://github.com/docker/docker-py/pull/3115 * Fix co |
| `6.1.0` | 2023-05-05 | Low | ## ℹ️ Upgrade Notes - Errors are no longer returned during client initialization if the credential helper cannot be found. A warning will be emitted instead, and an error is returned if the credential helper is used.  ## ✨ Features - Python 3.11 support - Use `poll()` instead of `select()` on non-Windows platforms - New API fields   - `network_driver_opt` on container run / create   - `one-shot` on container stats   - `status` on services list  ## 🐛 Bugfixes - Support for requests 2 |
| `6.0.1` | 2022-11-02 | Low | ## ⚠️ Notice This version is not compatible with `requests` 2.29+ or `urllib3` 2.x. Either add `requests < 2.29` and `urllib3 < 2` to your requirements or upgrade to to the [latest `docker-py` release](https://github.com/docker/docker-py/releases/latest).  ## 🐛 Bugfixes * Fix for `The pipe has been ended` errors on Windows (#3056) * Support floats for timestamps in Docker logs (`since` / `until`) (#3031)  ## What's Changed * docs: install package in ReadTheDocs build by @milas in https |

## Citation

- HTML: https://www.freshcrate.ai/projects/docker
- Markdown: https://www.freshcrate.ai/projects/docker.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/docker/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
