Giter Club home page Giter Club logo

cargo's Introduction

cargo

Docker Containers for Humans™

⚠️ WARNING This is a very early alpha release of cargo. APIs are subject to change. All development for this project is being done in the open. Contributions and critiques are totally welcome, but please at least announce and discuss your plans via an issue before submitting a pull request so we can all collectively create something beautiful!

Examples

inspect currently running local containers

>>> from cargo import Dock
>>> d = Dock()
>>> d.containers
[<Container [9a7a6a52171d]>, <Container [b575c9ece1b9]>, <Container [b225c9398c4b]>]

Alternatively, you can get the same result with cargo.ps:

>>> import cargo
>>> cargo.ps()
[<Container [9a7a6a52171d]>, <Container [b575c9ece1b9]>, <Container [b225c9398c4b]>]

get dock metadata

>>> d 
<Dock [http://localhost:4243] (1.3)>
>>> d.info
{u'NFd': 28, u'MemoryLimit': True, u'NGoroutines': 36, u'Images': 112, u'Debug': False, u'Containers': 189}
>>> d.memory_limit
True

inspect command string running in container

>>> container = d.containers[0]
>>> container.command
u'python -m SimpleHTTPServer'

inspect forwarded container ports

In this example, we're forwarding port 49155 locally to port 8000 within the container.

>>> container = d.containers[0]
>>> container.ports
[(49155, 8000)]

inspect container logs

In this example we are running python -m SimpleHTTPServer to fire up a basic HTTP server on port 8000. We use container.ports to grab out the locally forwarded port, issue an HTTP GET using python requests, and then inspect the subsequent container logs, which now contain an apache logs entry for our GET request, ✨ as if by magic! ✨

>>> import cargo
>>> import requests
>>> container = cargo.ps()[0]
>>> container
<Container [9a7a6a52171d]>
>>> container.command
u'python -m SimpleHTTPServer'
>>> container.logs
u''
>>> requests.get('http://localhost:%s' % (container.ports[0][0]))
<Response [200]>
>>> container.logs
u'172.16.42.1 - - [11/Aug/2013 12:49:56] "GET / HTTP/1.1" 200 -\n'

Demo

Link to ascii.io demo

License

cargo is MIT licensed.

cargo's People

Contributors

mkovaxx avatar mvanveen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cargo's Issues

Switch to using mocks in unit testing

Cargo currently functionally testing some of the output from Dock objects within unit tests, which is dependent on the current docker state. This is bad.

We should mock our unit tests, and also create a functional suite where we can bring up a container from scratch and test it functionally (#metalevelconcerns will likely apply).

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.