Giter Site home page Giter Site logo

fabric-docker's Introduction

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:

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

fabric-docker's People

Contributors

malexer avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.