gcc
GCC Overview
Secure your stack with a hardened GCC image freshly-built by Minimus. Minimus images always include the most up-to-date package version for all packages and dependencies contained in the image.
GCC (GNU Compiler Collection) is used to build C applications that are compatible with glibc. It's possible to use a multi-stage build with glibc-dynamic as a minimal runtime base. Learn how it's done
Try It Out
You can use the GCC image from Minimus to compile C programs or CPP programs.
To compile a C program:
docker run --rm -v "${PWD}:/app" -w /app reg.mini.dev/gcc gcc -o hello hello.cIf you don't have a C program on hand, you can download the example from Minimus.
To compile a CPP program (provided you have a hello.cpp program in your pwd):
docker run --rm -v "${PWD}:/app" -w /app reg.mini.dev/gcc g++ -o hello hello.cppNext, run the compiled program (provided you have a compiled hello program in your pwd):
docker run --rm -v "${PWD}:/app" -w /app --entrypoint ./hello reg.mini.dev/gccYou should see the printout: Minimus says hello world.
Ready to build using Dockerfile?
Now you are ready to build a minimal, secure app using the Minimus GCC image. Save the following to a Dockerfile:
FROM reg.mini.dev/gcc AS builder
WORKDIR /build
COPY hello.c hello.cpp ./
RUN gcc -static hello.c -o hello-c && g++ -static hello.cpp -o hello-cpp
FROM reg.mini.dev/gcc
WORKDIR /app
COPY --from=builder /build/hello-c /build/hello-cpp .
ENTRYPOINT ["/bin/sh", "-c", "./hello-c && ./hello-cpp"]Next, build your custom image and run it. Note that the period . specifies the current directory as the build context:
docker build -t minimus-gcc .
docker run --rm minimus-gccReady to use glibc-dynamic as a runtime base?
You can use a multi-stage build with glibc-dynamic as a runtime base to create a more minimal app.
Save the following to a Dockerfile:
FROM reg.mini.dev/gcc AS builder
WORKDIR /build
COPY hello.c ./
RUN gcc -o hello hello.c
FROM reg.mini.dev/glibc-dynamic
COPY --from=builder /build/hello /usr/bin/
USER 65532
ENTRYPOINT ["/usr/bin/hello"] Next, build your custom image and run it. Note that the period . specifies the current directory as the build context:
docker build -t gcc-glibc .
docker run --rm gcc-glibcTechnical Considerations
The GCC image provided by Minimus is a slim, security-hardened alternative to the public image from Docker Hub. The images are largely interchangeable, with a few differences as noted below.
GCC built by Minimus:
- Runs as root to support required functions.
- The default entrypoint is
/usr/bin/gcc. The public image defaults to a shell. You can use the --entrypoint argument to override the entrypoint if needed. - Drill down on the version specification tab to see the default user, listening ports, entrypoint, volumes, environment variables, etc.
The Payoff
A hardened, minimal image that will remain more secure for the long run and accrue vulnerabilities at a slower rate.
- See the risk reduction dashboard for a detailed CVE comparison over the past 30 days.
- Review the compliance report to see the default hardening and security configurations for the image.
Terms & Info
Trademark
This catalog is published by Minimus. All product names, logos, and marks, other than those belonging to Minimus, shown are owned by their respective rights holders and appear here only to identify the open source software each image contains. Minimus claims no ownership of those marks and implies no affiliation with, endorsement by, certification by, or sponsorship by any rights holder.
Disclaimer
Images are provided "as-is" without warranty of any kind. "Hardened" refers to the security configuration applied at the time of build and does not constitute a guarantee of ongoing security or absence of vulnerabilities. The free tier is provided without support, SLA, or guaranteed patching timelines. Security updates may be applied to paid subscriptions before or instead of free tier images. By pulling or using any image you agree to our Terms of Use.