Please explain multiple images in an executor

A common use-case for multiple Docker images would be to spin up a Postgres DB container that needs to be available for certain tests. Multiple Docker images are most useful when you need to connect to a resource over the network.

If you are looking to install some CSS/JS assets with node on a PHP app, your best bet would probably be to make use of the -node convenience images and something like circleci/php:7.4-cli-node

https://circleci.com/docs/2.0/circleci-images/#language-image-variants

Here’s a list of all the image variants:

https://circleci.com/docs/2.0/docker-image-tags.json

That will give you PHP with a node executable available to compile your assets. If you need a specific version of node, its probably simplest to make use of the node Orb to install a different version as opposed to using the -node image variant

https://circleci.com/orbs/registry/orb/circleci/node

There is an old blog post that talks about how to access resources in a secondary container and speaks of the hoops you would need to jump through to do that

So to sum things up, multiple Docker containers are most useful when you want to access a network resource like a database for your builds. If you need access to something additional, like node, you usually want to simply install it during the build.

2 Likes