summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBen Firshman <ben@firshman.co.uk>2016-11-07 17:56:02 -0800
committerBen Firshman <ben@firshman.co.uk>2016-11-22 17:05:43 +0000
commit1984f68730512a1c07017118f4e229c7949ff8a8 (patch)
tree00768c0a70d67b4a221333a8566534e8e58a008f /README.md
parentf32c0c170917518b7e224adf8627e95b5e620a91 (diff)
downloaddocker-py-1984f68730512a1c07017118f4e229c7949ff8a8.tar.gz
Add new user-focused API
See #1086 Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Diffstat (limited to 'README.md')
-rw-r--r--README.md77
1 files changed, 62 insertions, 15 deletions
diff --git a/README.md b/README.md
index 876ed02..094b13c 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,73 @@
-docker-py
-=========
+# Docker SDK for Python
[![Build Status](https://travis-ci.org/docker/docker-py.png)](https://travis-ci.org/docker/docker-py)
-A Python library for the Docker Remote API. It does everything the `docker` command does, but from within Python – run containers, manage them, pull/push images, etc.
+A Python library for the Docker API. It lets you do anything the `docker` command does, but from within Python apps – run containers, manage containers, manage Swarms, etc.
-Installation
-------------
+## Installation
-The latest stable version is always available on PyPi.
+The latest stable version [is available on PyPi](https://pypi.python.org/pypi/docker/). Either add `docker` to your `requirements.txt` file or install with pip:
- pip install docker-py
+ pip install docker
-Documentation
--------------
+## Usage
-[![Documentation Status](https://readthedocs.org/projects/docker-py/badge/?version=latest)](https://readthedocs.org/projects/docker-py/?badge=latest)
+Connect to Docker using the default socket or the configuration in your environment:
-[Read the full documentation here](https://docker-py.readthedocs.io/en/latest/).
-The source is available in the `docs/` directory.
+```python
+import docker
+client = docker.from_env()
+```
+You can run containers:
-License
--------
-Docker is licensed under the Apache License, Version 2.0. See LICENSE for full license text
+```python
+>>> client.containers.run("ubuntu", "echo hello world")
+'hello world\n'
+```
+
+You can run containers in the background:
+
+```python
+>>> client.containers.run("bfirsh/reticulate-splines", detach=True)
+<Container '45e6d2de7c54'>
+```
+
+You can manage containers:
+
+```python
+>>> 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:
+
+```python
+>>> for line in container.logs(stream=True):
+... print line.strip()
+Reticulating spline 2...
+Reticulating spline 3...
+...
+```
+
+You can manage images:
+
+```python
+>>> client.images.pull('nginx')
+<Image 'nginx'>
+
+>>> client.images.list()
+[<Image 'ubuntu'>, <Image 'nginx'>, ...]
+```
+
+[Read the full documentation](https://docs.docker.com/sdk/python/) to see everything you can do.