Skip to content
This repository has been archived by the owner on Sep 5, 2021. It is now read-only.

Docker image that initialises cache volumes for Batect.

License

Notifications You must be signed in to change notification settings

batect/batect-cache-init-image

batect-cache-init-image

🛑 As of Batect 0.74.0, this image is no longer used and so has been deprecated. It is no longer maintained.


Build Status License Chat

A Docker image that initialises cache volumes for Batect.

Why is this necessary?

Docker volumes have two major drawbacks when used for caches:

  • If they are empty (including if they've just been created), then everything in the target directory of the next container they're mounted into is copied into the volume - this is potentially time consuming and can lead to unexpected behaviour.

  • By default, they're mounted into the container with root as the owner, so if the container is running as a non-root user, it can't use the directory - which presents problems for containers running with Batect's 'run as current user' mode.

Batect uses this image to initialise cache volumes before they're used by a user's containers:

  • If the volume is empty, it creates a dummy file (.cache-init) in the root of the volume to stop Docker copying the contents of the target container's directory into the volume.

  • If the target container is running with 'run as current user' mode, it sets the owner and group of the volume to the desired user so that the volume can be used successfully.