Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/malexer/fabric-docker
Docker command-line tool wrapper for Fabric.
https://github.com/malexer/fabric-docker
Last synced: about 1 month ago
JSON representation
Docker command-line tool wrapper for Fabric.
- Host: GitHub
- URL: https://github.com/malexer/fabric-docker
- Owner: malexer
- License: mit
- Created: 2016-03-11T15:52:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-03-11T17:27:37.000Z (over 8 years ago)
- Last Synced: 2024-10-01T08:23:27.731Z (about 2 months ago)
- Language: Python
- Size: 7.81 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
fabric-docker
=============Docker-engine command-line tool wrapper for Fabric.
Can be used both in local and remote modes (via subprocess or ssh).
Method names and options try to use the same names as related docker-engine
commands and options.So, it is mainly a helper to write:
.. code-block:: python
docker.ps(all=True, size=True)
instead of:
.. code-block:: python
run('docker ps --all --size')
With some nice use cases:
.. code-block:: python
# remove dangling images ":"
docker.rmi(docker.none_images())# remove images by some filter
images = [
image['image id'] for image in docker.images()
if image['tag'] != 'latest'
]
docker.rmi(images)Requirements
------------* Docker (local or remote - depending the mode you use)
* Fabric
* pyyamlSupported commands
------------------Only limited set of commands and options are supported now:
* cli - run arbitrary Docker command. i.e. ``docker.cli('ps -a')``
* images
* ps
* restart
* rm
* rmi
* run - limited set of options
* start
* stop
* version
* none_images - helper method to get "dangling" imagesInstall
-------.. code::
pip install fabric-docker
Usage
-----Create instance to use locally with sudo:
.. code-block:: python
import fabric_docker
docker = fabric_docker.DockerCli(local=True, use_sudo=True)
# any command can override this default settings by suppling
# "local" and "sudo" key-value argumentsList all local containers:
.. code-block:: python
docker.ps(all=True)
Remove latest container:
.. code-block:: python
docker.rm(docker.ps(latest=True))
List remote images (override default local flag):
.. code-block:: python
docker.images(no_truncate=True, local=False)
Run remote container:
.. code-block:: python
docker.run(
detach=True,
restart='always',
publish={'8080':'80'},
volume={'/host/dir': '/container/dir', '/host/dir2': '/container/dir2'},
name='name_of_container',
image='image_name:tag',
)