瀏覽代碼

Set the container's hostname to the truncated ID

Solomon Hykes 12 年之前
父節點
當前提交
54fa59c8ec
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      runtime.go

+ 7 - 1
runtime.go

@@ -69,9 +69,15 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) {
 	if err != nil {
 		return nil, err
 	}
+	// Generate id
+	id := GenerateId()
+	// Generate default hostname
+	if config.Hostname == "" {
+		config.Hostname = id[:12]
+	}
 	container := &Container{
 		// FIXME: we should generate the ID here instead of receiving it as an argument
-		Id:              GenerateId(),
+		Id:              id,
 		Created:         time.Now(),
 		Path:            config.Cmd[0],
 		Args:            config.Cmd[1:], //FIXME: de-duplicate from config