GithubHelp home page GithubHelp logo

bhanditz / docker-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from airbnb/docker-client

0.0 2.0 0.0 133 KB

Docker client library to access the Docker remote API.

License: MIT License

Ruby 100.00%

docker-client's Introduction

Docker Client

Docker client library to access the Docker remote API.

Installation

Add this line to your application's Gemfile:

gem 'docker-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install docker-client

Usage

Ready to be used with Docker version 0.4.0.

So far only the containers resource is supported. The images resource and endpoints in category misc according to the Docker Remote API documentation are not yet implemented (wip: see pull request)

require 'docker'
require 'awesome_print'

docker = Docker::API.new(base_url: 'http://localhost:4243')
containers = docker.containers

# Create a new container
result = containers.create(['/bin/sh', '-c', 'while true; do echo hello world; sleep 1; done'], 'base')
container_id = result["Id"]
ap result

# Start created container
containers.start(container_id)

# Get container details (inspect)
details = containers.show(container_id)
ap details

# Get file system changes of container
changes = containers.changes(container_id)
ap changes

# Attach to container for 3 seconds
options = {stdout: true, stderr: false}
containers.attach(container_id, options, 3) do |data|
  puts ">> #{data}"
end

# Get all output since container is started
output = containers.logs(container_id)
ap output

# List all running containers
running_containers = containers.list
ap running_containers

# Stop container
containers.stop(container_id)

# Remove container
containers.remove(container_id)

Development

Run tests

All tests are stubbed with VCR. You can edit the setting config.default_cassette_options in spec_helper.rb to run the tests against the docker API. Set it to {:record => :all}. This will alos re-record all VCR request/response. To run the tests stubbed again uncomment the before mentioned setting.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT License. Copyright 2013 Georg Kunz.

docker-client's People

Contributors

geku avatar sridatta avatar vito avatar donpdonp avatar

Watchers

James Cloos 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.