Categorygithub.com/syb-devs/dockerlink
modulepackage
0.0.0-20141216144457-633e5a2694bc
Repository: https://github.com/syb-devs/dockerlink.git
Documentation: pkg.go.dev

# README

Dockerlink

Build Status

Dockerlink is a small package to get data (IP Address, port, protocol) of a linked Docker container.

More about Docker linking

Usage example

Given two containers setup as follows:

$ docker run -d --name db mongo
$ docker run -d -P --name goweb --link db:db myrepo/goapp

Where the first one is running a MongoDB server and the second one is our Golang web app, we could use the package to get the IP address and port to connect to the MongoDB database from within our Go app in the second container:

package main

import (
	"github.com/syb-devs/dockerlink"
	"gopkg.in/mgo.v2"
)

func main() {
	link, err := dockerlink.GetLink("db", 27017, "tcp")
	if err != nil {
		panic(err)
	}

	session, err := mgo.Dial(fmt.Sprintf("%s:%d", link.Address, link.Port))
	if err != nil {
		panic(err)
	}
	...
}

# Functions

GetLink returns a Link configured with Docker defined environment vars.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Link represents a Docker container link.