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

huangapple go评论76阅读模式
英文:

Error:fork/exec : no such file or directory -- when run Golang code in docker

问题

首先,非常感谢您的帮助。

我想在容器中执行Gocode:

FROM index.tenxcloud.com/tenxcloud/centos:centos7
ADD ./ping-app /wls/applications/ping-app
RUN yum install -y gcc libxml2-devel libxslt-devel && ldconfig
RUN yum install -y openssh-server net-tools telnet
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN mkdir -p /wls/logs/ && touch /wls/logs/ping-app.log
ADD run.sh /run.sh
CMD ["/run.sh"]

但是当我尝试在容器中执行时,出现以下错误:

[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时却没有问题。

环境:

Centos: 7.0.1406

Kubernetes: 1.2.0

Docker: 1.10.3

非常感谢您的任何建议。

英文:

first of all any help is appreciated

I want execute Gocode in a container:

FROM index.tenxcloud.com/tenxcloud/centos:centos7
ADD ./ping-app /wls/applications/ping-app
RUN yum install -y gcc libxml2-devel libxslt-devel && ldconfig
RUN yum install -y openssh-server net-tools telnet
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN mkdir -p /wls/logs/ && touch /wls/logs/ping-app.log
ADD run.sh /run.sh
CMD ["/run.sh"]

but when I try and execute in a container I get the following error:

[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

I can't understand why this is happening and it only happened in docker, but when I run that Gocode on the host and it is ok.

Environment :

Centos: 7.0.1406

Kubernetes: 1.2.0

docker: 1.10.3

Thanks a lot for any suggestions.

答案1

得分: 1

抱歉,我发现我忘记将一个命令复制到容器中,而这个命令是exec.Command需要运行的。不管怎样,谢谢你的帮助。

英文:

sorry I have found that I missed to copy a command to container which exec.Command need to run. Anyway,thanks for help

huangapple
  • 本文由 发表于 2016年12月10日 09:33:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/41071276.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定