I want to use docker to compile a custom PHP executable.

I plan to use alpine as a base image, installing the required tools (build-essentials, etc).

The goal is to have the most minimalist resulting image for later use in child images.

Would it make sense to tar the resulting php binary and publish to a host, and later have the child layers just pull in the php binary?

Or does it make sense to keep the original image? What happens to all the build tools and libraries? Do they become part of the image?


1 Answer 1


This is what I would to better handle the base docker images lifecycle:

  • Create a git repo to save your Dockerfile + configs
  • Create a Dockerfile with alpine + all the configs/libraries you want
  • Add your php.ini + php-cli.ini configs
  • Have a Jenkins job to start on each push to that repo:
    • Build your docker image
    • Tag it incrementally
    • Push to your registry
  • Use that base image to create your final docker image

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.