docker


Namedocker JSON
Version 7.0.0 PyPI version JSON
download
home_pagehttps://github.com/docker/docker-py
SummaryA Python library for the Docker Engine API.
upload_time2023-12-08 20:42:25
maintainerDocker, Inc.
docs_urlNone
author
requires_python>=3.8
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # 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/). Either add `docker` to your `requirements.txt` file or 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/docker/docker-py",
    "name": "docker",
    "maintainer": "Docker, Inc.",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "no-reply@docker.com",
    "keywords": "",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/25/14/7d40f8f64ceca63c741ee5b5611ead4fb8d3bcaf3e6ab57d2ab0f01712bc/docker-7.0.0.tar.gz",
    "platform": null,
    "description": "# Docker SDK for Python\n\n[![Build Status](https://github.com/docker/docker-py/actions/workflows/ci.yml/badge.svg)](https://github.com/docker/docker-py/actions/workflows/ci.yml)\n\nA Python library for the Docker Engine API. It lets you do anything the `docker` command does, but from within Python apps \u2013 run containers, manage containers, manage Swarms, etc.\n\n## Installation\n\nThe latest stable version [is available on PyPI](https://pypi.python.org/pypi/docker/). Either add `docker` to your `requirements.txt` file or install with pip:\n\n    pip install docker\n\n> Older versions (< 6.0) required installing `docker[tls]` for SSL/TLS support.\n> This is no longer necessary and is a no-op, but is supported for backwards compatibility.\n\n## Usage\n\nConnect to Docker using the default socket or the configuration in your environment:\n\n```python\nimport docker\nclient = docker.from_env()\n```\n\nYou can run containers:\n\n```python\n>>> client.containers.run(\"ubuntu:latest\", \"echo hello world\")\n'hello world\\n'\n```\n\nYou can run containers in the background:\n\n```python\n>>> client.containers.run(\"bfirsh/reticulate-splines\", detach=True)\n<Container '45e6d2de7c54'>\n```\n\nYou can manage containers:\n\n```python\n>>> client.containers.list()\n[<Container '45e6d2de7c54'>, <Container 'db18e4f20eaa'>, ...]\n\n>>> container = client.containers.get('45e6d2de7c54')\n\n>>> container.attrs['Config']['Image']\n\"bfirsh/reticulate-splines\"\n\n>>> container.logs()\n\"Reticulating spline 1...\\n\"\n\n>>> container.stop()\n```\n\nYou can stream logs:\n\n```python\n>>> for line in container.logs(stream=True):\n...   print(line.strip())\nReticulating spline 2...\nReticulating spline 3...\n...\n```\n\nYou can manage images:\n\n```python\n>>> client.images.pull('nginx')\n<Image 'nginx'>\n\n>>> client.images.list()\n[<Image 'ubuntu'>, <Image 'nginx'>, ...]\n```\n\n[Read the full documentation](https://docker-py.readthedocs.io) to see everything you can do.\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "A Python library for the Docker Engine API.",
    "version": "7.0.0",
    "project_urls": {
        "Changelog": "https://docker-py.readthedocs.io/en/stable/change-log.html",
        "Documentation": "https://docker-py.readthedocs.io",
        "Homepage": "https://github.com/docker/docker-py",
        "Source": "https://github.com/docker/docker-py",
        "Tracker": "https://github.com/docker/docker-py/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "18bd9706c10bb12e05043ef138dc8d412cfd17f29c8df0fb28ad71c96a98785d",
                "md5": "fc452eeb4f06e64c31bff825b56df18a",
                "sha256": "12ba681f2777a0ad28ffbcc846a69c31b4dfd9752b47eb425a274ee269c5e14b"
            },
            "downloads": -1,
            "filename": "docker-7.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc452eeb4f06e64c31bff825b56df18a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 147565,
            "upload_time": "2023-12-08T20:42:23",
            "upload_time_iso_8601": "2023-12-08T20:42:23.580361Z",
            "url": "https://files.pythonhosted.org/packages/18/bd/9706c10bb12e05043ef138dc8d412cfd17f29c8df0fb28ad71c96a98785d/docker-7.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25147d40f8f64ceca63c741ee5b5611ead4fb8d3bcaf3e6ab57d2ab0f01712bc",
                "md5": "b08eeccf6a5efd11c316c08207edfeef",
                "sha256": "323736fb92cd9418fc5e7133bc953e11a9da04f4483f828b527db553f1e7e5a3"
            },
            "downloads": -1,
            "filename": "docker-7.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b08eeccf6a5efd11c316c08207edfeef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 258536,
            "upload_time": "2023-12-08T20:42:25",
            "upload_time_iso_8601": "2023-12-08T20:42:25.225032Z",
            "url": "https://files.pythonhosted.org/packages/25/14/7d40f8f64ceca63c741ee5b5611ead4fb8d3bcaf3e6ab57d2ab0f01712bc/docker-7.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-08 20:42:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "docker",
    "github_project": "docker-py",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "docker"
}
        
Elapsed time: 0.16618s