Docker CLI

Buddy offers a complete collection of tools and services required to build, test and deploy Docker images. Users who demand more flexibility in their process can use the Docker CLI action. The action runs commands on an Ubuntu VM with preinstalled Docker CLI in the context of the Git repository to which the pipeline is attached.

This is especially useful for operations that require:

  • docker-compose
  • privileged access to Docker containers (Docker-in-Docker)
  • access to the Docker daemon

Docker CLI in action rosterDocker CLI in action roster

Docker images built with Docker CLI are not available for Docker Push and Docker Run actions in the pipeline. In other words, if you want to build an image on the VM and then push it to the registry, you must do both operations from the CLI.

Caching

When the action is run, Buddy copies the files from the pipeline filesystem with the clone of the repository to the VM with Docker. Once finished, the output is transferred back to the filesystem (by default /home/ubuntu/build) and the VM is killed. If you are building or pulling images from the VM, you can attach a drive to cache images, layers, and containers and speed up your delivery process.

To enable caching, go to Options and check 'Attach cache drive to VM running this action'. This will mount a drive to the /var/lib/docker path.

The default size of the drive is 10 GB. If you need more space, please contact our support team.

Sharing cache with other actions

By default, each Docker CLI action uses its own cache attached to the host VM. If you are running multiple CLI actions, you can force them to share the same cache by checking the 'Use shared cache drive' option.

Make sure that the scope and drive tag in both actions are the same.

Parallelism

If you run two actions sharing the same cache in parallel, the second action will create another drive and use it independently until the interval between pipeline runs is more than 7 days (disk retention period).

Clearing cache

If you purge the pipeline cache, all drives attached to Docker CLI actions will be removed – even if they are shared with actions in other pipelines.

The exception is the Clear cache action that lets you precisely define what should be purged.

Containers in shared cache

If you run a container in the action (e.g. docker run --name mongo-db -d mongo) and do not kill it manually in the end, the container image will remain in the cache. This means that if you run the container in another Docker CLI action sharing the same cache, it will fail with an error like this:

docker: Error response from daemon: Conflict. The container name "/mongo-db" is already in use`.

To solve this, launch the container with docker start instead of docker run. For example:

docker start mongo-db
$

See also

Introduction
Docker in CI/CD process
Docker image push on every tag push