mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-10-05 09:53: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:
@@ -2,7 +2,6 @@ package services
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
ptypes "github.com/franela/play-with-docker/types"
|
||||
@@ -75,18 +74,13 @@ func AttachExecConnection(execId string, ctx context.Context) (*types.HijackedRe
|
||||
return &conn, nil
|
||||
}
|
||||
|
||||
func CreateInstance(net string) (*ptypes.Instance, error) {
|
||||
func CreateInstance(net string, dindImage string) (*ptypes.Instance, error) {
|
||||
|
||||
var maximumPidLimit int64
|
||||
maximumPidLimit = 150 // Set a ulimit value to prevent misuse
|
||||
h := &container.HostConfig{NetworkMode: container.NetworkMode(net), Privileged: true}
|
||||
h.Resources.PidsLimit = maximumPidLimit
|
||||
|
||||
dindImage := os.Getenv("DIND_IMAGE")
|
||||
if len(dindImage) == 0 {
|
||||
dindImage = "docker:1.12.2-rc2-dind"
|
||||
}
|
||||
|
||||
conf := &container.Config{Image: dindImage}
|
||||
container, err := c.ContainerCreate(context.Background(), conf, h, nil, "")
|
||||
|
||||
|
Reference in New Issue
Block a user