dqrq93879
2017-06-09 00:17
浏览 72

Golang docker库映像无法在$ PATH中找到go工具

I opened an issue on docker-library/golang#164, because I think this is a bug. However, I thought I'd also ask on StackOverflow to see if anyone else (besides project contributors) have encountered this or have any ideas?

First things first, the version numbers:

$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true

$ docker-compose version
docker-compose version 1.11.2, build dfed245
docker-py version: 2.1.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

I'm getting the following error:

Cannot start service web: oci runtime error: container_linux.go:247: starting container process caused "exec: \"go\": executable file not found in $PATH"

And this is my Dockerfile:

FROM golang:1.8

WORKDIR /go/src/gigem
COPY . /go/src/gigem

RUN go build
RUN go install

CMD ["gigem"]

I'm also using Compose (and I'll include the yml, but the error occurs with/without compose):

version: '3'
services:
  db:
    image: postgres
    volumes:
      - ./data:/var/lib/postgresql/data
  web:
    build: .
    volumes:
      - .:/go/src/gigem
    ports:
      - "3000:3000"
    depends_on:
      - db

And all that's in my Go program is:

package main

import (
  "fmt"
  "net/http"
)

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello Docker!")
  })

  fmt.Println("Running!")
  fmt.Println(http.ListenAndServe("0.0.0.0:3000", nil))
}

I'm not quite sure why go is not being found in the $PATH.

图片转代码服务由CSDN问答提供 功能建议

我在 docker-library / golang#164 ,因为我认为这是一个错误。 但是,我想我也要在StackOverflow上询问是否有其他人(除项目贡献者之外)遇到此问题或有任何想法?

首先要注意的是版本号:

  $ docker version 
Client:
版本:17.03.1-ce 
 API版本:1.27 
 Go版本:go1.7.5 
 Git提交:c6d412e 
内置 :2017年3月28日星期二00:40:02 
 OS / Arch:darwin / amd64 
 
服务器:
版本:17.03.1-ce 
 API版本:1.27(最低版本1.12)
 Go版本:go1  .7.5 
 Git提交:c6d412e 
内置:3月24日星期五00:00:50 2017 
 OS / Arch:linux / amd64 
实验:true 
 
 $ docker-compose版本
docker-compose版本1.11  .2,构建dfed245 
docker-py版本:2.1.0 
CPython版本:2.7.12 
OpenSSL版本:OpenSSL 1.0.2j 2016年9月26日
   
 
 

I 'm出现以下错误:

 无法启动服务网站:oci运行时错误:container_linux.go:247:启动容器进程导致“ exec:\” go \”:可执行文件 文件 在$ PATH中找不到“ 
   
 
 

,这是我的 Dockerfile

  从golang:1.8 
 
WORKDIR / go / src / gigem 
COPY。  / go / src / gigem 
 
RUN go build 
RUN go install 
 
CMD [“ gigem”] 
   
 
 

我也在使用Compose(和 我将包含yml,但在有/无撰写的情况下都会发生错误):

 版本:'3'
services:
 db:
图片:postgres 
 卷:
-./data:/var/lib/postgresql/data
网站:
构建:。
卷:
-。:/ go / src / gigem 
端口:
-“ 3000  :3000“ 
depends_on:
-db 
   
 
 

而我的Go程序中的全部内容是:

 包main 
 
import(
“ fmt” 
“ net / http” 
)
 
func main(){
 http.HandleFunc(“ /”,func(w http.ResponseWriter,r *  http.Request){
 fmt.Fprintf(w,“ Hello Docker!”)
})
 
 fmt.Println(“ Running!”)
 fmt.Println(http.ListenAndServe(“ 0.0.0.0  :3000“,nil))
} 
   
 
 

我不太确定为什么在 $ PATH 中找不到go

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douji5329 2017-06-09 13:41
    已采纳

    From the comments, I tested this code myself without error (admittedly on 17.06-rc2 but the behavior shouldn't change). Given that a restart solved this, there appears to have been some corruption inside of docker that needed a bounce to correct (while rare, it wouldn't be the first time I've seen this). For others encountering problems in the future, I like to try the following in order:

    1. Pull fresh images and/or rebuild without caching for any issues with the layers
    2. Restart docker for possible corruption inside the daemon
    3. Restart the entire host for runtime configuration issues that persist outside of the docker daemon
    4. With dockerd stopped, wipe /var/lib/docker which will destroy all containers, images, and volumes (so backup first) and start clean
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题