January 6, 2022
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.
- 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.
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.
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).
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.
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:
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:
docker start my-redis
Customer Success Manager