Docker 正在運行,創建了一個容器,但返回:無法連接到 unix 上的 Docker 守護程序:///var/run/docker.sock 作為響應。Docker 守護程序是否正在運行?ContainerExecCreateContainerExecAttach可能是什么問題。import ( "archive/tar" "bytes" "context" "fmt" "io" "io/ioutil" "log" "net" "os" "strconv" "strings" "time" client "docker.io/go-docker" "docker.io/go-docker/api/types" "docker.io/go-docker/api/types/container" "docker.io/go-docker/api/types/network" "docker.io/go-docker/api/types/swarm" "docker.io/go-docker/api/types/volume" "github.com/containerd/containerd/reference" "github.com/play-with-docker/play-with-docker/config")func (d *docker) ExecAttach(instanceName string, command []string, out io.Writer) (int, error) { e, err := d.c.ContainerExecCreate(context.Background(), instanceName, types.ExecConfig{Cmd: command, AttachStdout: true, AttachStderr: true, Tty: true}) if err != nil { return 0, err } resp, err := d.c.ContainerExecAttach(context.Background(), e.ID, types.ExecConfig{AttachStdout: true, AttachStderr: true, Tty: true}) if err != nil { return 0, err }}
- 1 回答
- 0 關注
- 132 瀏覽
添加回答
舉報
0/150
提交
取消