Skip to content

Commit 8461075

Browse files
committed
docs: add to docker howto
Describe the `parent`, `definition` and `args` entries supported by the docker_image transforms.
1 parent 8197cf8 commit 8461075

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

docs/howto/docker.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,65 @@ process the ``Dockerfile`` and handle the special syntax. Whereas the
201201
only generated once and then re-used by all subsequent pushes until the image
202202
is modified.
203203

204+
Layering images on top of each other
205+
....................................
206+
207+
The `parent` value on a docker-image task can refer to another image's `name`.
208+
The parent image can then be referenced from the dependent image's Dockerfile
209+
as `$DOCKER_IMAGE_PARENT`. Whenever the base image's definition (or
210+
something it includes) changes, that automatically also triggers a
211+
rebuild of the dependent image.
212+
213+
For example, `kind.yml` could include:
214+
215+
.. code-block:: yaml
216+
217+
tasks:
218+
base:
219+
symbol: I(base)
220+
extras:
221+
symbol: I(extras)
222+
parent: base
223+
224+
And the `extras` image's Dockerfile:
225+
226+
.. code-block::
227+
228+
FROM $DOCKER_IMAGE_PARENT
229+
230+
RUN apt-get update && apt-get install -y extra software && apt-get clean
231+
232+
233+
.. note::
234+
The `taskgraph build-image` command doesn't handle this syntax, so it won't work for those images.
235+
In taskcluster this is handled by the image_builder tool, see
236+
`the image_builder docker image <https://hub.docker.com/r/mozillareleases/image_builder>`_ and
237+
`its source code <https://searchfox.org/mozilla-central/source/taskcluster/docker/image_builder>`_.
238+
239+
240+
Reusing image definitions
241+
.........................
242+
243+
The same `Dockerfile` can be used for multiple images, by setting `definition`, for example:
244+
245+
.. code-block:: yaml
246+
247+
tasks:
248+
debian12:
249+
symbol: I(deb12)
250+
definition: debian
251+
args:
252+
BASE_IMAGE: debian:12
253+
debian11:
254+
symbol: I(deb11)
255+
definition: debian
256+
args:
257+
BASE_IMAGE: debian:11
258+
259+
Both the `debian11` and `debian12` images will be built from the definition in
260+
`taskcluster/docker/debian`, but they'll be passed different `BASE_IMAGE`
261+
variables (as in `docker build --build-arg`).
262+
204263
Context Directory Hashing
205264
~~~~~~~~~~~~~~~~~~~~~~~~~
206265

0 commit comments

Comments
 (0)