错误:fork / exec:没有这样的文件或目录 - 在docker中运行Golang代码时

时间:2016-12-10 01:33:43

标签: go docker kubernetes

首先感谢任何帮助

我想在容器中执行Gocode,但是当我尝试在容器中执行时,我收到以下错误:

[root@ping-app-3618687774-abqmo ping-app]# go run main.go 
start check_server
INFO[0000] http.startHttpServer ok, listening 0.0.0.0:8080  source="api.go:106"
INFO[0000] Index=ipdata exists=true                      source="elastic.go:164"
INFO[0000] Index=ipdata Type=entity exists=true          source="elastic.go:184"
fork/exec : no such file or directory
fork/exec : no such file or directory
fork/exec : no such file or directory
fork/exec : no such file or directory
fork/exec : no such file or directory
fork/exec : no such file or directory
fork/exec : no such file or directory
fork/exec : no such file or directory

我无法理解为什么会发生这种情况,而且只发生在docker中,但是当我在主机上运行Gocode时就可以了。

Environment :

Centos: 7.0.1406

Kubernetes: 1.2.0

docker: 1.10.3

非常感谢任何建议。

2 个答案:

答案 0 :(得分:1)

抱歉,我发现我错过了将命令复制到exec.Command需要运行的容器。无论如何,谢谢你的帮助

答案 1 :(得分:-2)

你的dockerfile中的

你也应该复制fork / exec。 在您的go代码中,您正在读取fork / exec,并且在容器内找不到它,因此导致此错误。