mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 01:57:32 +08:00
- Fix .gitignore
- Note about bug with Docker driver - Implement experimental pid ulimit of 150.
This commit is contained in:
parent
97f39ca375
commit
74e8502f3f
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
play-with-docker
|
||||
|
@ -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, "")
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user