我有一个小项目,我的服务器将http发送的C文件复制到Docker容器中,在那里编译和运行它们.但是,我无法获取任何数据发送到容器中的stdout.
我已确定将文件发送到Docker容器中,还有更多 - 编译的任何问题都显示在错误流中.但是,在C程序中通过stderr发送数据也没有显示任何结果,直到我使用Dockerfile,使用'>&2 echo""'以某种方式将数据推送到流中并且我能够读取它.
现在,如上所述,我只能阅读stderr,完全归功于一种解决方法.知道为什么我不能使用标准方法吗?
去服务器
package main
import (
"fmt"
"net/http"
"io"
"os"
"os/exec"
"log"
"encoding/json"
"github.com/docker/docker/client"
dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"golang.org/x/net/context"
"time"
"bytes"
)
type Result struct {
CompilationCode int
RunCode int
TestsPositive int
TestsTotal int
}
func upload(w http.ResponseWriter, r *http.Request) {
log.Println("method:", r.Method)
if r.Method == "POST" {
log.Println("Processing new SUBMISSION.")
// https://github.com/astaxie/build-web-application-with-golang/blob/master/de/04.5.md
r.ParseMultipartForm(32 << 20)
file, handler, err := r.FormFile("file")
if err != nil {
fmt.Println(err)
return
}
defer file.Close()
baseName:= os.Args[1]
f, err := …Run Code Online (Sandbox Code Playgroud)