1

So I am experimenting with Docker and I am contemplating a possibility of compiling a source tree on my local machine, using gcc & make and some more dependent libraries from a Docker container running locally.

Is it even possible? If yes, how do I go about it?

1 Answer 1

2

It's possible. There's an official gcc image that does exactly that. There's a couple of example Dockerfiles on their dockerhub page, that will help you get started:

FROM gcc:4.9
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN gcc -o myapp main.c
CMD ["./myapp"]

Or, without building an image:

$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:4.9 gcc -o myapp myapp.c
Sign up to request clarification or add additional context in comments.

1 Comment

what this does is - it creates a temporary (--rm) docker container, mounts the local folder as a volume (-v) compiles and exits, leaving only the resulting binary left.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.