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
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 hashes)
Built Distribution
Close
Hashes for dockercontext-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39edd52a02e2b9cd9fc7574b9998efb556a0fb46510945c31c0b866b87a86178 |
|
MD5 | 9ef249226fdbb0982c7d99175aff8149 |
|
BLAKE2b-256 | e795604e92141ba7e2484f0c542625bb22ed07c591122c35465218f8403c2366 |