Skip to content

Commit

Permalink
Make sure instances have unique names.
Browse files Browse the repository at this point in the history
Make sure we don't return an old docker client.
  • Loading branch information
xetorthio committed Sep 13, 2017
1 parent d566e5e commit c4859e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker/local_cached_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (f *localCachedFactory) GetForSession(sessionId string) (DockerApi, error)
}

func (f *localCachedFactory) GetForInstance(instance *types.Instance) (DockerApi, error) {
key := instance.SessionId + instance.IP
key := instance.Name

f.irw.Lock()
c, found := f.instanceClients[key]
Expand Down
3 changes: 2 additions & 1 deletion provisioner/dind.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"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/storage"
"github.com/rs/xid"
)

type DinD struct {
Expand Down Expand Up @@ -58,7 +59,7 @@ func (d *DinD) InstanceNew(session *types.Session, conf types.InstanceConfig) (*
}
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{
Image: conf.ImageName,
SessionId: session.Id,
Expand Down

0 comments on commit c4859e1

Please sign in to comment.