<p>This is what I would to better handle the base docker images lifecycle:</p>
<ul>
<li>Create a git repo to save your Dockerfile + configs</li>
<li>Create a Dockerfile with alpine + all the configs/libraries you want</li>
<li>Add your php.ini + php-cli.ini configs</li>
<li>Have a Jenkins job to start on each push to that repo:
<ul>
<li>Build your docker image</li>
<li>Tag it incrementally</li>
<li>Push to your registry</li>
</ul>
</li>
<li>Use that base image to create your final docker image</li>
</ul>

CC BY-SA 4.0
2021-03-05T01:51:02.053Z
2021-03-05T01:51:02.053Z
Akram Fares
<p>I want to use docker to compile a custom PHP executable.</p>
<p>I plan to use alpine as a base image, installing the required tools (build-essentials, etc).</p>
<p>The goal is to have the most minimalist resulting image for later use in child images.</p>
<p>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?</p>
<p>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?</p>

CC BY-SA 4.0
2021-02-26T17:55:03.070Z
Looks at multi-stage builds - they usually serve this purpose - https://docs.docker.com/develop/develop-images/multistage-build/
taleodor
CC BY-SA 4.0
2021-03-13T17:22:30.537Z
You can create multi stage builds or a base (parent) image
again
<docker>
Docker image, containers and layers
Alex.Barylski
# Docker image, containers and layers

(Asked by: username_0 on 2021-02-26)

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?

**Tags:** docker

> **Comments:**
> **username_1**: Looks at multi-stage builds - they usually serve this purpose - https://docs.docker.com/develop/develop-images/multistage-build/  
> **username_2**: You can create multi stage builds or a base (parent) image  

---

## 1 answers

### Answer by username_3 on 2021-03-05. Score: 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


---

