1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-05 18:03:21 +08:00

Allow dind image to be overriden.

- improve readme - mention pre-pulling dind image.
- read env variable once in init() method
This commit is contained in:
Alex
2016-10-09 19:49:34 +01:00
parent 11749c4902
commit 7df6bacee5
3 changed files with 28 additions and 12 deletions

View File

@@ -1,19 +1,37 @@
package services
import "github.com/franela/play-with-docker/types"
import (
"log"
"os"
"github.com/franela/play-with-docker/types"
)
var instances map[string]map[string]*types.Instance
var dindImage string
var defaultDindImageName string
func init() {
instances = make(map[string]map[string]*types.Instance)
dindImage = getDindImageName()
}
func getDindImageName() string {
dindImage := os.Getenv("DIND_IMAGE")
defaultDindImageName = "docker:1.12.2-rc2-dind"
if len(dindImage) == 0 {
dindImage = defaultDindImageName
}
return dindImage
}
func NewInstance(session *types.Session) (*types.Instance, error) {
//TODO: Validate that a session can only have 10 instances
//TODO: Validate that a session can only have 5 instances
//TODO: Create in redis
instance, err := CreateInstance(session.Id)
log.Printf("NewInstance - using image: [%s]\n", dindImage)
instance, err := CreateInstance(session.Id, dindImage)
if err != nil {
return nil, err