如何在docker remote api中创build容器? (去-dockerclient)

我正在使用go-dockerclient库,我想使用CreateContainer go-dockerclient方法创build容器,但是我应该在哪里传递泊坞窗图像ID我创build此function

func CreateContainer(w http.ResponseWriter, r *http.Request){ client,err:=docker.NewTLSClient(Endpoint,Cert,Key,Ca) if err!=nil{ panic(err) } container,er:=client.CreateContainer(docker.CreateContainerOptions{Name:"cont"}) if er!=nil{ panic(err) } } 

例如,如果我有一个给定的图像ID我应该在哪里添加它?

您可以在configuration结构中指定图像:

  container, err := client.CreateContainer(docker.CreateContainerOptions{ Name: "container name", Config: &docker.Config{ Image: "ubuntu:latest", }, })