Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When trying to build docker image, I get ""gcc": executable file not found in $PATH"

Tags:

docker

windows

go

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
like image 548
Janis Lange Avatar asked Dec 24 '19 16:12

Janis Lange


People also ask

What is path in Docker build?

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.

What is GCC Docker?

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).

What is executable Docker image?

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.


2 Answers

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 
like image 77
Jim Avatar answered Oct 05 '22 02:10

Jim


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" ]
like image 23
valo Avatar answered Oct 05 '22 02:10

valo