Skip to main content

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:

docker.ps(all=True, size=True)

instead of:

run('docker ps --all --size')

With some nice use cases:

# remove dangling images "<none>:<none>"
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

  • pyyaml

Supported 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” images

Install

pip install fabric-docker

Usage

Create instance to use locally with sudo:

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 arguments

List all local containers:

docker.ps(all=True)

Remove latest container:

docker.rm(docker.ps(latest=True))

List remote images (override default local flag):

docker.images(no_truncate=True, local=False)

Run remote container:

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',
)

Release files for fabric-docker 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fabric-docker 0.1
File Size Uploaded
fabric-docker-0.1.tar.gz 5.3 kB Details

Release files / fabric-docker-0.1.tar.gz

Download URL fabric-docker-0.1.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0cf7cfda8f8b448d9910341d6c8bb0921aa1d04b8639880026a6854fc79356f3
BLAKE2b-256 checksum
How to use checksums
a3fa6b57b2732bcaadc23a2058428e7debc6fe53966528b71d9cb0de0b71732f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page