Docker

We can specify Docker containers for our jobs to run by using the container key. To it we pass an object with an image key, its value being the image that we will be using. Additionally, we can specify the env (for environment variables that need to be available in the container), ports (to specify ports to be exposed in the container), volumes, options (to be used in the Docker create command). All steps in the job will run in de container, and not on the virtual machine.

Docker 1
Docker 2

We can also specify multiple containers. To specify multiple containers we pass an object to the services key. Each element of that object is the key that identifies each one of our services. In order to communicate between the two containers we can use the service key (name) as a host name.

We can specify different containers for different steps. To do so, we simply pass the Docker image to uses keyword of the respective steps.

Docker 3