Giter VIP home page Giter VIP logo

erldocker's Introduction

erldocker

erldocker is an Erlang application that implements Docker Remote API v1.4.

Public modules are: docker, docker_container and docker_image.

Setting up

To get started, add erldocker app to your release applications list. If you don't use releases, check out the Makefile.

Configuration

Check out run/sys.config. By default, docker listens on the unix socket serving HTTP. Since Erlang doesn't have something like gen_unix by default, I'm using erldocker_unixbridge that spawns socat to bridge AF_UNIX to AF_INET.

    {erldocker, [
            {unixbridge_port, 32133},
            {docker_http, <<"http://localhost:32133">>}
    ]}

If your docker is configured to listen on a TCP port, you may use the following configuration:

    {erldocker, [
            {docker_http, <<"http://localhost:4243">>}
    ]}

Erlang APIs

The APIs are pretty straightforward in general. Please note that the library is under heavy development and some of the APIs (namely the ones that use POST bodies) are not very nice as of right now. This will change without further notice.

Check out the examples:

> docker_container:containers().
{ok,[[{'Id',<<"6274938616c28e82b49b3ab120f9e9b9d96592d3b5bb95b53e91f740aca76243">>},
      {'Image',<<"base:latest">>},
      {'Command',<<"/bin/bash -c while true; do sleep 1; date; done">>},
      {'Created',1378278965},
      {'Status',<<"Up About an hour">>},
      {'Ports',<<>>},
      {'SizeRw',0},
      {'SizeRootFs',0}],
     [{'Id',<<"a574cdc01fa64e9b7e359d8d76f734505a4d9d121e39af877fab8c14a5d93baf">>},
      {'Image',<<"base:latest">>},
      {'Command',<<"/bin/bash -c while true; do sleep 1; date; done">>},
      {'Created',1378278960},
      {'Status',<<"Up About an hour">>},
      {'Ports',<<>>},
      {'SizeRw',0},
      {'SizeRootFs',0}]]}

> docker_container:attach_stream("687264242").
{ok,<0.167.0>}

> flush().
Shell got {<0.167.0>,{data,<<"Wed Sep  4 08:52:18 UTC 2013\n">>}}
Shell got {<0.167.0>,{data,<<"Wed Sep  4 08:52:19 UTC 2013\n">>}}
Shell got {<0.167.0>,{data,<<"Wed Sep  4 08:52:20 UTC 2013\n">>}}
ok

> exit(pid(0,167,0), kill).
** exception exit: killed

> docker_container:kill("687264242").
{ok,{204,<<>>}}

> {ok, Info} = docker_container:container("687264242"),
  {_, Image} = lists:keyfind('Image', 1, Info).
{'Image',<<"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc">>}

> docker_image:image(Image).
{ok,[{id,<<"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc">>},
     {parent,<<"27cf784147099545">>},
     {created,<<"2013-03-23T22:24:18.818426-07:00">>},
     {container,<<"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0">>},
     {container_config,[{'Hostname',<<>>},
                        {'User',<<>>},
                        {'Memory',0},
                        {'MemorySwap',0},
                        {'CpuShares',0},
                        {'AttachStdin',false},
                        {'AttachStdout',false},
                        {'AttachStderr',false},
                        {'PortSpecs',null},
                        {'Tty',true},
                        {'OpenStdin',true},
                        {'StdinOnce',false},
                        {'Env',null},
                        {'Cmd',[<<"/bin/bash">>]},
                        {'Dns',null},
                        {'Image',<<"base">>},
                        {'Volumes',null},
                        {'VolumesFrom',<<>>},
                        {'WorkingDir',...},
                        {...}|...]},
     {'Size',24653}]}

erldocker's People

Contributors

proger avatar tsloughter avatar

Watchers

Gleb Peregud avatar Paul Peregud avatar James Cloos 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.