Giter Club home page Giter Club logo

docker.rs's Introduction

docker.rs

A docker API wrapper library for rust.

Development

docker.rs is currently under development, follow the below instructions to get started.

  • Install rustc and rust-toolchain.
  • Clone the repository.
  • Jump to src/ and start hacking.

Usage

docker_rs provides a rust interface to interact with Docker API. It is currently build to support latest version(1.37) of docker API. To get started make sure you have the docker daemon up.

  • For now only API implementation for only containers is available. I will be adding the rest soon.

Connecting to docker unix socket interface.

let client = match DockerClient::new("unix:///var/run/docker.sock") {
    Ok(a) => a,
    Err(err) => {
        println!("{}", err);
        exit(1);
    }
};

Using API methods inherited by DockerApiClient.

// Get version info for docker
let info = client.get_version_info();

// Get all containers(running/stopped)
let all_containers = client.list_all_containers(None).unwrap();

// Get only running containers
let running_cont = client.list_running_containers(None).unwrap();

// Create a new container using an Image
let mut cmd: Vec<String> = Vec::new();
cmd.push("ls".to_string());
let res = client
    .create_container_minimal("kk", "debian:jessie", cmd)
    .unwrap();

// Inspect the info for a container.
let inspect_info = client
    .inspect_container(
        "f808ca866b5fa80f65d6cd0937c72049272ea4c5aa4453e2abdd08d5efb59d3d",
    )
    .unwrap();

// Get info regarding changes made to filesystem inside container
let inspect_info = client
    .get_container_filesystem_changes(
        "f808ca866b5fa80f65d6cd0937c72049272ea4c5aa4453e2abdd08d5efb59d3d",
    )
    .unwrap();


// Start a created container
let start_info = client.start_container("f808ca...").unwrap();

// Kill a container
let kill_info = client.kill_container("f808ca...").unwrap();

The library currently only provides unix socket interface support for communicating with docker daemon and is therefore fit for most purposes wherein the docker daemon you are interacting is local. To add an implementation of HTTP capable DockerClient look at the implementation of unix socket in /src/client.rs.

The only required method for implementing DockerApiClient is request wherein you make a request to the docker API and returns the response. Once you have this you can implement each of api helpers like Containers for your client which uses this function itself.

External Links

License

This project is licensed under MIT License

Development notes

  • docker-rs encourage you to keep your code foramtted using rustfmt.
  • For any feature you add to the library, write proper documentation according to rust standards.

docker.rs's People

Contributors

fristonio avatar

Watchers

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