1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-07-14 18:27:25 +08:00

- Fix .gitignore

- Note about bug with Docker driver
- Implement experimental pid ulimit of 150.
This commit is contained in:
Alex 2016-10-09 18:58:32 +02:00
parent 97f39ca375
commit 74e8502f3f
3 changed files with 11 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
play-with-docker

View File

@ -29,10 +29,14 @@ func GetContainerInfo(id string) (types.ContainerJSON, error) {
}
func CreateNetwork(name string) error {
// TODO: This line appears to give an error when running on localhost:3000
// when driver is specified a name must be given.
opts := types.NetworkCreate{Attachable: true, Driver: "overlay"}
_, err := c.NetworkCreate(context.Background(), name, opts)
if err != nil {
log.Printf("Starting session err [%s]\n", err)
return err
}
@ -72,7 +76,11 @@ func AttachExecConnection(execId string, ctx context.Context) (*types.HijackedRe
func CreateInstance(net 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
conf := &container.Config{Image: "docker:dind"}
container, err := c.ContainerCreate(context.Background(), conf, h, nil, "")

View File

@ -18,6 +18,7 @@ func NewSession() (*types.Session, error) {
s := &types.Session{}
s.Id = uuid.NewV4().String()
s.Instances = map[string]*types.Instance{}
log.Printf("NewSession id=[%s]\n", s.Id)
//TODO: Store in something like redis
sessions[s.Id] = s