需要幫助。我有從 docker 容器執行命令的代碼。需要從 exec 命令中獲取 stdout。execConfig:= types.ExecConfig{Tty:false,AttachStdout:true,AttachStderr:false,Cmd:command} respIdExecCreate,err := cli.ContainerExecCreate(context.Background(),dockerName,execConfig) if err != nil { fmt.Println(err) } respId,err:=cli.ContainerExecAttach(context.Background(),respIdExecCreate.ID,types.ExecStartCheck{}) if err != nil { fmt.Println(err) } scanner := bufio.NewScanner(respId.Reader) for scanner.Scan() { fmt.Println(output)}從輸出中我看到有趣的情況: 來自 gyazo 的屏幕如何正確刪除字節?我發送簡單的命令 := []string{"echo","-n", "hello word"}
來自 golang api 的 Docker exec 命令
慕蓋茨4494581
2023-04-24 15:46:20