All Projects → samalba → Dockerclient

samalba / Dockerclient

Licence: apache-2.0
Docker client library in Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Dockerclient

Keylogger
Keylogger is 100% invisible keylogger not only for users, but also undetectable by antivirus software. Blackcat keylogger Monitors all keystokes, Mouse clicks. It has a seperate process which continues capture system screenshot and send to ftp server in given time.
Stars: ✭ 271 (-16.1%)
Mutual labels:  client
Study
A simple, progressive, client/server AB testing library 📚
Stars: ✭ 293 (-9.29%)
Mutual labels:  client
Cdrs
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async
Stars: ✭ 314 (-2.79%)
Mutual labels:  client
Messenger
Package messenger is used for making bots for use with Facebook messenger
Stars: ✭ 278 (-13.93%)
Mutual labels:  client
Elasticsearch Net
Elasticsearch.Net & NEST
Stars: ✭ 3,181 (+884.83%)
Mutual labels:  client
Websocket Client
🔧 .NET/C# websocket client library
Stars: ✭ 297 (-8.05%)
Mutual labels:  client
Php Fastcgi Client
Lightweight, single file, FastCGI client for PHP
Stars: ✭ 270 (-16.41%)
Mutual labels:  client
Mimic
📡 League from the safety of your toilet.
Stars: ✭ 320 (-0.93%)
Mutual labels:  client
Libmqtt
MQTT v3.1.1/5.0 library in Go
Stars: ✭ 290 (-10.22%)
Mutual labels:  client
Go Elasticsearch
The official Go client for Elasticsearch
Stars: ✭ 3,817 (+1081.73%)
Mutual labels:  client
Eiskaltdcpp
File sharing program using DC and ADC protocols
Stars: ✭ 277 (-14.24%)
Mutual labels:  client
Tg
terminal telegram client that really works
Stars: ✭ 281 (-13%)
Mutual labels:  client
Elasticsearch Py
Official Elasticsearch client library for Python
Stars: ✭ 3,486 (+979.26%)
Mutual labels:  client
Hiredis Vip
Support redis cluster. Maintained and used at vipshop.
Stars: ✭ 274 (-15.17%)
Mutual labels:  client
Netcat
💻 Netcat client and server modules written in pure Javascript for Node.js.
Stars: ✭ 315 (-2.48%)
Mutual labels:  client
Android Ddp
[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Stars: ✭ 271 (-16.1%)
Mutual labels:  client
Orion
Cross platform Twitch.tv client
Stars: ✭ 298 (-7.74%)
Mutual labels:  client
Haxor News
Browse Hacker News like a haxor: A Hacker News command line interface (CLI).
Stars: ✭ 3,342 (+934.67%)
Mutual labels:  client
Universa
Universa network, node, client and API
Stars: ✭ 322 (-0.31%)
Mutual labels:  client
Ccql
Multi server MySQL client
Stars: ✭ 313 (-3.1%)
Mutual labels:  client

Docker client library in Go

GoDoc

No longer well-maintained docker client library. Docker's supported engine API client for go is docker/engine-api.

How to use it?

Here is an example showing how to use it:

package main

import (
	"github.com/samalba/dockerclient"
	"log"
	"time"
	"os"
)

// Callback used to listen to Docker's events
func eventCallback(event *dockerclient.Event, ec chan error, args ...interface{}) {
	log.Printf("Received event: %#v\n", *event)
}

func main() {
	// Init the client
	docker, _ := dockerclient.NewDockerClient("unix:///var/run/docker.sock", nil)

	// Get only running containers
	containers, err := docker.ListContainers(false, false, "")
	if err != nil {
		log.Fatal(err)
	}
	for _, c := range containers {
		log.Println(c.Id, c.Names)
	}

	// Inspect the first container returned
	if len(containers) > 0 {
		id := containers[0].Id
		info, _ := docker.InspectContainer(id)
		log.Println(info)
	}

	// Build a docker image
	// some.tar contains the build context (Dockerfile any any files it needs to add/copy)
	dockerBuildContext, err := os.Open("some.tar")
	defer dockerBuildContext.Close()
	buildImageConfig := &dockerclient.BuildImage{
			Context:        dockerBuildContext,
			RepoName:       "your_image_name",
			SuppressOutput: false,
	}
	reader, err := docker.BuildImage(buildImageConfig)
	if err != nil {
		log.Fatal(err)
	}

	// Create a container
	containerConfig := &dockerclient.ContainerConfig{
		Image: "ubuntu:14.04",
		Cmd:   []string{"bash"},
		AttachStdin: true,
		Tty:   true}
	containerId, err := docker.CreateContainer(containerConfig, "foobar", nil)
	if err != nil {
		log.Fatal(err)
	}

	// Start the container
	hostConfig := &dockerclient.HostConfig{}
	err = docker.StartContainer(containerId, hostConfig)
	if err != nil {
		log.Fatal(err)
	}

	// Stop the container (with 5 seconds timeout)
	docker.StopContainer(containerId, 5)

	// Listen to events
	docker.StartMonitorEvents(eventCallback, nil)

	// Hold the execution to look at the events coming
	time.Sleep(3600 * time.Second)
}

Maintainers

List of people you can ping for feedback on Pull Requests or any questions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].