Spin up docker containers for easy in-line testing
Project description
Scylla
Spin up docker containers inline with python code for easier testing
Install
git clone https://github.com/talosiot/scylla.git
make env
from IPython.core.display import display, HTML
import requests
import scylla
Run a docker container. If there are ports that the container needs, specify them in a list. If you want to wait until a certain port is available, you can specify that here as well. For example, to run a small web server you need port 80 and you want to wait until it is available.
container = scylla.run_container(image='httpd:alpine', ports=[80], block_until_port_available=80)
container.ports
{'80/tcp': [{'HostIp': '0.0.0.0', 'HostPort': '8228'}]}
The container is running and you can interact with it.
host_d = scylla.lookup_host(container, container_port=80)
url = 'http://{HostIp}:{HostPort}'.format(**host_d)
resp = requests.get(url)
print(resp.text)
display(HTML(resp.text))
<html><body><h1>It works!</h1></body></html>
It works!
Stop the container any time. Or, it will automatically stop at the end of the program.
container.stop()
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
scylla-for-docker-0.0.2.tar.gz
(10.0 kB
view details)
File details
Details for the file scylla-for-docker-0.0.2.tar.gz.
File metadata
- Download URL: scylla-for-docker-0.0.2.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c80e693ea3bda900c9cb5012197881f4a893e4e3af8df6ab7c852239585575e
|
|
| MD5 |
24bed72b826f59342cb9797266ea576f
|
|
| BLAKE2b-256 |
36996455485dd0c5202ac3000dd2da7dcebe0979f9f0f225e5b61acc9aca7200
|