Looking to do something similar to the example below but for several containers. I could manually add the volumes and name (used to create a container specific backup directory, stop container before backup, pull additional details from docker inspect) but wouldn't it be nice if they could be picked up and provided automatically?
Given the following stripped docker compose:
version: "3"
...
nginx:
image: nginx
volumes:
- nginx_config: /etc/nginx
labels:
chadburn.enabled: "true"
chadburn.job-run.backup-volumes.schedule: "@every 1h"
chadburn.job-run.backup-volumes.command: "backup volumes full"
chadburn.job-run.backup-volumes.image: custom-backup:latest
chadburn.job-run.backup-volumes.volume: ["/opt/backups:/backup:rw"]
chadburn.job-run.backup-volumes.provide: ["name", "volumes"]
chadburn.job-run.backup-volumes.env: ["id=my_id", "key=my_key"]
this would result in the following:
docker run --rm -e name=nginx -e id=my_id -e key=my_key -v /opt/backups:/backups:rw -v nginx_config:/etc/nginx custom-backup:latest backup volumes full
an exec example would be the same, but I can't see any way to pass volumes so would have to skip that!
docker run --rm -e name=nginx -e id=my_id -e key=my_key custom-backup:latest backup volumes full
"provide" takes an array of properties from the container it's specified on, useful things that come to mind would be container name, volumes, ip, environment vars, labels
Thinking too much about it, it could just be docker inspect values in some sort of dot notation like .Config.Hostname, .Config.Image, .Config.Labels["com.docker.compose.project"], .Config.Env["my_env"] to make it flexible
env would be for additional environment variables to pass to the new container or existing container.
The main thing I was looking for was a way to identify the container that the new container/exec was triggered for!, but I got carried away with dreams and came up with the above!
Looking to do something similar to the example below but for several containers. I could manually add the volumes and name (used to create a container specific backup directory, stop container before backup, pull additional details from docker inspect) but wouldn't it be nice if they could be picked up and provided automatically?
Given the following stripped docker compose:
version: "3"
...
nginx:
image: nginx
volumes:
- nginx_config: /etc/nginx
labels:
chadburn.enabled: "true"
chadburn.job-run.backup-volumes.schedule: "@every 1h"
chadburn.job-run.backup-volumes.command: "backup volumes full"
chadburn.job-run.backup-volumes.image: custom-backup:latest
chadburn.job-run.backup-volumes.volume: ["/opt/backups:/backup:rw"]
chadburn.job-run.backup-volumes.provide: ["name", "volumes"]
chadburn.job-run.backup-volumes.env: ["id=my_id", "key=my_key"]
this would result in the following:
docker run --rm -e name=nginx -e id=my_id -e key=my_key -v /opt/backups:/backups:rw -v nginx_config:/etc/nginx custom-backup:latest backup volumes full
an exec example would be the same, but I can't see any way to pass volumes so would have to skip that!
docker run --rm -e name=nginx -e id=my_id -e key=my_key custom-backup:latest backup volumes full
"provide" takes an array of properties from the container it's specified on, useful things that come to mind would be container name, volumes, ip, environment vars, labels
Thinking too much about it, it could just be docker inspect values in some sort of dot notation like .Config.Hostname, .Config.Image, .Config.Labels["com.docker.compose.project"], .Config.Env["my_env"] to make it flexible
env would be for additional environment variables to pass to the new container or existing container.
The main thing I was looking for was a way to identify the container that the new container/exec was triggered for!, but I got carried away with dreams and came up with the above!