Make sure instances have unique names.
Make sure we don't return an old docker client.
This commit is contained in:
@@ -58,7 +58,7 @@ func (f *localCachedFactory) GetForSession(sessionId string) (DockerApi, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *localCachedFactory) GetForInstance(instance *types.Instance) (DockerApi, error) {
|
func (f *localCachedFactory) GetForInstance(instance *types.Instance) (DockerApi, error) {
|
||||||
key := instance.SessionId + instance.IP
|
key := instance.Name
|
||||||
|
|
||||||
f.irw.Lock()
|
f.irw.Lock()
|
||||||
c, found := f.instanceClients[key]
|
c, found := f.instanceClients[key]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/play-with-docker/play-with-docker/pwd/types"
|
"github.com/play-with-docker/play-with-docker/pwd/types"
|
||||||
"github.com/play-with-docker/play-with-docker/router"
|
"github.com/play-with-docker/play-with-docker/router"
|
||||||
"github.com/play-with-docker/play-with-docker/storage"
|
"github.com/play-with-docker/play-with-docker/storage"
|
||||||
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DinD struct {
|
type DinD struct {
|
||||||
@@ -58,7 +59,7 @@ func (d *DinD) InstanceNew(session *types.Session, conf types.InstanceConfig) (*
|
|||||||
}
|
}
|
||||||
conf.Hostname = nodeName
|
conf.Hostname = nodeName
|
||||||
}
|
}
|
||||||
containerName := fmt.Sprintf("%s_%s", session.Id[:8], conf.Hostname)
|
containerName := fmt.Sprintf("%s_%s", session.Id[:8], xid.New().String())
|
||||||
opts := docker.CreateContainerOpts{
|
opts := docker.CreateContainerOpts{
|
||||||
Image: conf.ImageName,
|
Image: conf.ImageName,
|
||||||
SessionId: session.Id,
|
SessionId: session.Id,
|
||||||
|
|||||||
Reference in New Issue
Block a user