I have gcc on windows.
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.
My docker file:
FROM golang:alpine
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN go build -o main .
EXPOSE 8080
CMD [ "app/main" ]
When I try to build image I get error:
exec: "gcc": executable file not found in $PATH
Build with PATH , and so all the files in the local directory get tar d and sent to the Docker daemon. The PATH specifies where to find the files for the “context” of the build on the Docker daemon.
The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project that supports various programming languages. GCC is a key component of the GNU toolchain. The Free Software Foundation (FSF) distributes GCC under the GNU General Public License (GNU GPL).
A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
Add the gcc tools fixed the problem.
RUN apk add build-base
Also you can the this:
RUN apk --no-cache add make git gcc libtool musl-dev ca-certificates dumb-init
I encountered the same problem when building a go app using an alpine image. Installing gcc fixed the problem. Here is how your Dockerfile should look like:
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" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With