Copy files between containers on changes.
Go to file
Blake Rain a641c722a0
Deploy / build (push) Successful in 9s Details
fix: tag version
2023-10-13 15:43:35 +01:00
.gitea/workflows fix: tag version 2023-10-13 15:43:35 +01:00
src feat: add event specification in configuration (closes #1) 2023-10-13 15:32:02 +01:00
.gitignore feat: initial commit 2023-10-12 16:57:26 +01:00
Cargo.lock feat: add event specification in configuration (closes #1) 2023-10-13 15:32:02 +01:00
Cargo.toml feat: add event specification in configuration (closes #1) 2023-10-13 15:32:02 +01:00
Dockerfile fix: revert to scratch 2023-10-13 14:16:43 +01:00
LICENSE Initial commit 2023-10-12 14:52:07 +00:00 chore: update readme to reference new feature in #2 2023-10-13 15:32:50 +01:00 feat: initial commit 2023-10-12 16:57:26 +01:00

container-copier: Copy files between volumes on change

This repository contains a very simple tool called container-copier that will copy files from one location to another when the source file is changed. This tool uses inotify to receive notifications for when files are changed. This was developed to help me copy files between Docker volumes when they are changed.


The tool takes a TOML configuration file that specifies the files to copy. By default, the location of the file is expected to be /config/container-copier.toml, but this can be overriden with the --config argument or the CONFIG environment variable.

The TOML configuration file specifies the files to copy as targets within a copyset (there can be any number of either):

# Each copyset assigns a name (for logging) and a parent 'source' and
# 'target' directory.

name = "my_copyset"
source = "/data/source"
target = "/data/target"

# Each target specifies the 'source' and 'target' paths, where 'source' is
# the path to watch, and 'target' is the destination to copy to when changes
# are detected.
# Both 'source' and 'target' are each appended to the 'source' and 'target'
# fields in the copyset, respectively.

# Watch for changes to: '/data/source/file-1.txt'
source = "file-1.txt"
# When changed, copy to: '/data/target/file-1.txt'
target = "file-1.txt"


You can run container-copier in Docker by using the blakerain/container-copier image from Docker Hub (or by building it yourself). For example:

docker run \
    -v config.toml:/config/container-copier.toml \
    -v source_volume:/data/source \
    -v target_volume:/data/target \

Running as Root

Currently the user that is specified in the Dockerfile is 1000. For most intents and purposes this should be fine. However, there are cases where you will need container-copier to run as root to be able to access the contents of attached volumes. In which case, the user can be overridden with the --user argument to docker run. Note that the base image used is scratch, so there are no /etc/passwd entries (unless you add them). To use root you will need the numerical ID (UID) of the root user: 0:

docker run --user 0 \
    -v config.toml:/config/container-copier.toml \
    -v source_volume:/data/source \
    -v target_volume:/data/target \


There are currently a few restrictions:

  1. Each target must be a single file, there is no wildcard support (see #2).