Shared cache drives for Docker CLI

Shared cache drives for Docker CLI

At the end of 2021 we added a new action called Docker CLI. The action launches in a VM with preinstalled Docker and docker-compose, and terminates as soon as the action finishes.

This week, we upgraded this feature by adding the cache for Docker images, layers, and containers. This way, all images that you pull or build will be available for future pipeline executions. The functionality also allows you to transfer the cache between actions and pipelines. For example, you can build the image on the VM in one action, and then push it to the selected registry in another one.

What you need to know

  • To enable the cache, check the option 'Attach cache drive to VM running this action'.
  • To share the cache with other actions and pipelines, check 'Use shared cache drive'. You'll notice that new options have appeared allowing you to set the sharing scope (workspace > project > pipeline) and to define the tag for this cache.

Image loading...

Warning
In order to share the cache between different Docker CLI actions, make sure the sharing scope and the tag is the same in both of them.

How it works

The VM on which your run the commands defined in the Docker CLI action has a drive mounted to the /var/lib/docker tab. If you run a second Docker CLI action with the same sharing scope and tag, Buddy will mount that same drive to the second VM.

Running actions in parallel

The disk retention period is 7 days. If you run two actions using the same cache in parallel, the first one will use the existing drive, and the second one will create a new drive. If you run these two actions again, they will utilize the two separate drives respectively (unless the break between executions is more than 7 days).

Clearing pipeline cache

If you clear the pipeline cache (e.g. run it from scratch), Buddy will remove all cache drives used in this pipeline – even if they're shared with actions in other pipelines. The exception to this is the Clear Cache action in which you can precisely define what should be purged.

IMPORTANT:

Please be aware that if you run a container in action – for example, by running docker run --name my-redis -d redis – and will not remove it manually in the end, the container image will remain in the cache. This means that running the command again will throw an error like this:

default
docker: Error response from daemon: Conflict. The container name "/my-redis" is already in use`.

If you want to use the same container in subsequent actions, make sure to launch them using docker start, for example:

default
docker start my-redis
Warning
Each shared drive attached to the Docker VM has 10 GB of space. If you need more, please contact our support team.
Jarek Dylewski

Jarek Dylewski

Customer Support

A journalist and an SEO specialist trying to find himself in the unforgiving world of coders. Gamer, a non-fiction literature fan and obsessive carnivore. Jarek uses his talents to convert the programming lingo into a cohesive and approachable narration.

Jan 6th 2022
Share