Skip to main content

Docker API client for asyncio

Project description

PyPI version Python Versions Build Status Code Coverage

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

Installation

pip install aiodocker

For development version:

pip install 'git+https://github.com/aio-libs/aiodocker#egg=aiodocker'

Examples

import asyncio
import aiodocker

async def list_things():
    docker = aiodocker.Docker()
    print('== Images ==')
    for image in (await docker.images.list()):
        print(f" {image['Id']} {image['RepoTags'][0] if image['RepoTags'] else ''}")
    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()

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.7.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

aiodocker-0.7-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiodocker-0.7.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiodocker-0.7.tar.gz
Algorithm Hash digest
SHA256 b7983a35461abc2a0644bbd803a4c1e4b020519728b2997e2849567934ba77d6
MD5 f0e37c594077de070ed0b6359109a3e3
BLAKE2b-256 b6c0095d730cf4667f6b799a16f51a12d4d05133481c6b69e0ea436db5b2cfb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiodocker-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ae481a388f2b76040f01153d22ca982876a5ebbdef7f65bfd917a70a15fb73da
MD5 fbfd2bbf982b99dd3463b9ea547e482e
BLAKE2b-256 26e7a140e26fefca3729a3747204698097e63559c71184de95e996f88f52c464

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