Skip to main content

Run Docker containers within Python context manager

Project description

Docker Context

Run containers using with statement.

Example

import unittest
from urllib import request

from dockercontext import container


class ContextTest(unittest.TestCase):

    def test_response(self):
        with container.Context("nginx:alpine", {"80/tcp": 8080}):
            with request.urlopen("http://localhost:8080/") as response:
                self.assertEqual(response.code, 200)

    def test_container_id(self):
        with container.Context("nginx:alpine", {}) as ctx:
            self.assertEqual(64, len(ctx.container_id()))

        self.assertEqual(0, len(ctx.container_id()), ctx.container_id())

Note that although context blocks until container's state is running this does not meant that service inside container is ready.

Tests

$ python -m unittest

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

dockercontext-0.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

dockercontext-0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file dockercontext-0.1.tar.gz.

File metadata

  • Download URL: dockercontext-0.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for dockercontext-0.1.tar.gz
Algorithm Hash digest
SHA256 ebfd65d48227404318125dca1bad5336e9152a8b179cc6ff4f4993d2939ec5a0
MD5 0026487b9d5bdabe9e5337af0b5b585e
BLAKE2b-256 9a6d70444a898fc40fc660600197fff2484611ffe9aabe505d2926d667b88b4d

See more details on using hashes here.

File details

Details for the file dockercontext-0.1-py3-none-any.whl.

File metadata

  • Download URL: dockercontext-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for dockercontext-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39edd52a02e2b9cd9fc7574b9998efb556a0fb46510945c31c0b866b87a86178
MD5 9ef249226fdbb0982c7d99175aff8149
BLAKE2b-256 e795604e92141ba7e2484f0c542625bb22ed07c591122c35465218f8403c2366

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page