To add on to Lev’s post, the first container listed in a job is the “primary container”. Commands used in any steps for that job will all be run within the primary container. In the following example:
- image: circleci/python:3.6.1
- image: circleci/mongo:3.5.6
- run: echo "Hello World"
- run: mongo --version
circleci/python:3.6.1 is the primary image. This means that the commands that appear in “steps” which are
mongo both run from the primary image.
circleci/mongo:3.5.6 image means that CircleCI will run MongoDB in an additional container with the DB service being available via port
27017 (or whatever port you want to use) in the primary container.
mongo command, from the MongoDB CLI, and anything else you want to use still needs to be installed in the primary container. This can be done on the fly during your CI build (by writing the commands to install them in your CircleCI config) or by using a custom Docker image.