Skip to main content

Docker API client for asyncio

Project description

AsyncIO bindings for docker.io

PyPI version Python Versions Build Status Code Coverage Chat on Gitter

A simple Docker HTTP API wrapper written with asyncio and aiohttp.

Installation

pip install aiodocker

Documentation

http://aiodocker.readthedocs.io

Examples

import asyncio
import aiodocker

async def list_things():
    docker = aiodocker.Docker()
    print('== Images ==')
    for image in (await docker.images.list()):
        tags = image['RepoTags'][0] if image['RepoTags'] else ''
        print(image['Id'], tags)
    print('== Containers ==')
    for container in (await docker.containers.list()):
        print(f" {container._id}")
    await docker.close()

async def run_container():
    docker = aiodocker.Docker()
    print('== Running a hello-world container ==')
    container = await docker.containers.create_or_replace(
        config={
            'Cmd': ['/bin/ash', '-c', 'echo "hello world"'],
            'Image': 'alpine:latest',
        },
        name='testing',
    )
    await container.start()
    logs = await container.log(stdout=True)
    print(''.join(logs))
    await container.delete(force=True)
    await docker.close()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(list_things())
    loop.run_until_complete(run_container())
    loop.close()

Changes

0.16.0 (2019-09-23)

Bugfixes

  • Fix streaming mode for pull, push, build, stats and events. (#344)

0.15.0 (2019-09-22)

Features

  • Add support for Docker 17.12.1 and 18.03.1 (#164)

  • Add initial support for nodes. (#181)

  • Add initial support for networks. (#189)

  • Add support for docker info ando docker swarm join. (#193)

  • Add restart method for containers. (#200)

  • Feature: Add support for registry-auth when you create a service. (#215)

  • Feature: Add support for docker save and load api methods (#219)

  • Pass params to docker events. (#223)

  • Add ability to get a Docker network by name or ID. (#279)

  • Always close response after processing, make .logs(…, follow=True) async iterator. (#341)

Bugfixes

  • Fix: Set timeout for docker events to 0 (no timeout) (#115)

  • Fix: prevents multiple listener tasks to be created automatically (#116)

  • Fix: if container.start() fails user won’t get the id of the container (#128)

  • Improve logging when docker socket not available. (#155)

  • Fix current project version. (#156)

  • Fix update out of sequence. (#169)

  • Remove asserts used to check auth with docker registry. (#172)

  • Fix: fix to parse response of docker load method as a json stream (#222)

  • Fix: Handle responses with 0 or missing Content-Length (#237)

  • Fix: don’t remove non-newline whitespace from multiplexed lines (#246)

  • Fix docker_context.tar error (#253)

Deprecations and Removals

  • docker.images.get has been renamed to docker.images.inspect, remove support for Docker 17.06 (#164)

  • Drop Python 3.5 (#338)

  • Drop deprecated container.copy() (#339)

Misc

  • #28, #167, #192, #286

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiodocker-0.16.0.tar.gz (117.3 kB view details)

Uploaded Source

Built Distribution

aiodocker-0.16.0-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file aiodocker-0.16.0.tar.gz.

File metadata

  • Download URL: aiodocker-0.16.0.tar.gz
  • Upload date:
  • Size: 117.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for aiodocker-0.16.0.tar.gz
Algorithm Hash digest
SHA256 bb6eb2975db89d932daf4995704813cc40b52fcc59d3d4869ae349d7fe1c7659
MD5 32bb1358c43e79937dcb307ea2fb949c
BLAKE2b-256 27287d8b21c92a7ec8baa005303c32e83d7bb27220c73ea069f2aff00d59e7ee

See more details on using hashes here.

File details

Details for the file aiodocker-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: aiodocker-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for aiodocker-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40bb42ce1d44234cec1cc1fccd9b154482f0658b48008be8832ee98f955a8c76
MD5 d16c96d92b6be3b385732dcf115f8814
BLAKE2b-256 988f60c6c42d91a291e7e6cd68fa46cd379a084f8fe8a188d6989ab54fdb35d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page