dcind icon indicating copy to clipboard operation
dcind copied to clipboard

Caching docker directory to speed up image loading

Open fenech opened this issue 5 years ago • 3 comments

Hi, I have a Concourse build task that looks like

#!/bin/bash

source /docker-lib.sh
start_docker

docker load -i image1.tar
docker load -i image2.tar
docker load -i image3.tar

docker-compose up

The problem is that some of the images are quite large and this makes the task slow to run.

I thought that it might be possible to cache /scratch/docker in my build configuration:

caches: [{path: /scratch/docker}]

But it seems that this doesn't have any effect - docker images returns an empty list before I run docker load.

How can I cache the images loaded in previous builds to speed up my build task?

fenech avatar Aug 28 '19 13:08 fenech

@fenech Have you managed to find some kind of workaround ? I have similar problem now.

dsawa avatar Jun 05 '20 07:06 dsawa

@dsawa No, I couldn't find a way to persist the state between tasks runs using this image.

In the end I decided to change my approach: instead of using this task image, I SSH into a VM with Docker running there and pull the images rather than load them, so that layer caching can speed things up.

fenech avatar Jun 05 '20 07:06 fenech

Note that the concourse documention on caches states:

The path to a directory to be cached.

Paths are relative to the working directory of the task. Absolute paths are not respected.

I usually set up caches in concourse like this:

script in the task amounting to (.sbt is just an example directory):

rm -rf ~/.sbt
ln -fs sbt-cache ~/.sbt

cache configuration in the task declaration

caches:
- path: sbt-cache

Perhaps you could confirm if that approach works for you (applied to the directory /scratch/docker)?

georggrab avatar Jan 28 '21 17:01 georggrab