尝试构建docker映像时,出现““ gcc”:在$ PATH中找不到可执行文件”

时间:2019-12-24 16:48:01

标签: windows docker go

我在Windows上有gcc。

C:\Users\jkrov>gcc --version
gcc (MinGW.org GCC-8.2.0-5) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我的docker文件:

FROM golang:alpine
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN go build -o main .
EXPOSE 8080
CMD [ "app/main" ]

当我尝试构建图像时出现错误:

exec: "gcc": executable file not found in $PATH

2 个答案:

答案 0 :(得分:5)

使用高山图像构建Go应用时遇到了相同的问题。安装gcc可以解决此问题。这是您的Dockerfile的外观:

FROM golang:alpine
RUN apk add build-base
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN go build -o main .
EXPOSE 8080
CMD [ "app/main" ]

答案 1 :(得分:1)

添加gcc工具解决了该问题。

<div class="col-md-3">
                        <div class="form-group">
                            <label for="pwd">Last Name:</label> <input type="text"
                                class="form-control" name="last_name" ng-value="myVar">
                        </div>
                    </div>

还可以这样:

RUN apk add build-base