mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 18:27:25 +08:00
Fix undetected bugs in instance renaming
This commit is contained in:
parent
3ec374ed95
commit
861355d4e3
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
@ -94,7 +93,8 @@ func CreateInstance(session *Session, dindImage string) (*Instance, error) {
|
||||
session.Id: &network.EndpointSettings{Aliases: []string{nodeName}},
|
||||
},
|
||||
}
|
||||
container, err := c.ContainerCreate(context.Background(), conf, h, networkConf, fmt.Sprintf("%s_%s", session.Id[:4], nodeName))
|
||||
containerName := fmt.Sprintf("%s_%s", session.Id[:8], nodeName)
|
||||
container, err := c.ContainerCreate(context.Background(), conf, h, networkConf, containerName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -110,7 +110,7 @@ func CreateInstance(session *Session, dindImage string) (*Instance, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Instance{Name: strings.Replace(cinfo.Name, "/", "", 1), Hostname: cinfo.Config.Hostname, IP: cinfo.NetworkSettings.Networks[session.Id].IPAddress}, nil
|
||||
return &Instance{Name: containerName, Hostname: cinfo.Config.Hostname, IP: cinfo.NetworkSettings.Networks[session.Id].IPAddress}, nil
|
||||
}
|
||||
|
||||
func DeleteContainer(id string) error {
|
||||
|
@ -90,7 +90,7 @@ func (s *sessionWriter) Write(p []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
func (o *Instance) CollectStats() {
|
||||
reader, err := GetContainerStats(o.Hostname)
|
||||
reader, err := GetContainerStats(o.Name)
|
||||
if err != nil {
|
||||
log.Println("Error while trying to collect instance stats", err)
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user