| commit | 78439ebbe1aae77ff0fd9b666894d80807182e28 | [log] [tgz] |
|---|---|---|
| author | Mathieu Virbel <mat@kivy.org> | Thu Jun 01 14:19:01 2023 |
| committer | GitHub <noreply@github.com> | Thu Jun 01 14:19:01 2023 |
| tree | 8a754cbbd1ec7ebb5e347540c33583a238399876 | |
| parent | bc4c0d7cf4f6f794f9e92d93ddec02626eda739c [diff] |
fix: eventlet compatibility (#3132) Check if poll attribute exists on select module instead of win32 platform check The implementation done in #2865 is breaking usage of docker-py library within eventlet. As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (https://github.com/eventlet/eventlet/issues/608#issuecomment-612359458), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`. Fixes #3131 Signed-off-by: Mathieu Virbel <mat@meltingrocks.com>
A Python library for the Docker Engine API. It lets you do anything the docker command does, but from within Python apps – run containers, manage containers, manage Swarms, etc.
The latest stable version is available on PyPI. Either add docker to your requirements.txt file or install with pip:
pip install docker
Older versions (< 6.0) required installing
docker[tls]for SSL/TLS support. This is no longer necessary and is a no-op, but is supported for backwards compatibility.
Connect to Docker using the default socket or the configuration in your environment:
import docker client = docker.from_env()
You can run containers:
>>> client.containers.run("ubuntu:latest", "echo hello world") 'hello world\n'
You can run containers in the background:
>>> client.containers.run("bfirsh/reticulate-splines", detach=True) <Container '45e6d2de7c54'>
You can manage containers:
>>> client.containers.list() [<Container '45e6d2de7c54'>, <Container 'db18e4f20eaa'>, ...] >>> container = client.containers.get('45e6d2de7c54') >>> container.attrs['Config']['Image'] "bfirsh/reticulate-splines" >>> container.logs() "Reticulating spline 1...\n" >>> container.stop()
You can stream logs:
>>> for line in container.logs(stream=True): ... print(line.strip()) Reticulating spline 2... Reticulating spline 3... ...
You can manage images:
>>> client.images.pull('nginx') <Image 'nginx'> >>> client.images.list() [<Image 'ubuntu'>, <Image 'nginx'>, ...]
Read the full documentation to see everything you can do.