Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Compiling and running in different containers

I have a project which compiles to a binary file, and running that binary file exposes some REST APIs.

To compile the project I need docker image A which has the compiler and and all the libraries required to produce the executable. To run the executable (ie. host the service) I can get away with a much smaller image B (just basic linux distro, no need for the compiler).

How does one use docker is such a situation?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

My thinking for this scenario is that you can prepare two base images:

  • The 1st one, which includes compiler and all libs for building your executable, call it base-image:build
  • The 2nd one, as the base image to build your final image to delivery, call it base-image:runtime

And then break your build process into two steps:

  • Step 1: build your executable inside base-image:build, and then put your executable to some place, like NFS or any registry from where you can fetch it for later use;
  • Step 2: write your Dockerfile which FROM base-image:runtime, fetch your artifact/executable from wherever generated by Step 1, docker build your delivery image, and then docker push to your registry for release.

Hope this could be helpful :-)

about 4 years ago · Santiago Trujillo Report

0

mkdir local_dir
docker run -dv $PWD/local_dir:/mnt BUILD_CONTAINER

compile code and save it to /mnt in the container. It'll be written to local_dir on your host filesystem and persist after the container is destroyed.

You Should now write a Dockerfile and add a step to copy in the new binary, then build. But for example's sake...

docker run -dv $PWD/local_dir:/mnt PROD_CONTAINER 

Your bin, and everything else in local_dir, will reside in the container at /mnt/

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!