Closed xspio closed 8 months ago
I'm not sure what your question is, exactly.
If you've applied labels to your containers, you can export them with docker commands. You could use a bash script like what's below to list out your scheduled jobs by their labels prefixed with "chadburn".
# List all container IDs (including stopped ones)
container_ids=$(docker ps -aq)
# Iterate through each container ID and export its labels
for container_id in $container_ids; do
# Use docker inspect to get container metadata in JSON format and then extract labels
labels=$(docker inspect -f '{{json .Config.Labels}}' $container_id)
# Check if labels contain any key starting with "chadburn"
if [[ $labels == *\"chadburn* ]]; then
# Print the container ID and its labels
echo "Container ID: $container_id"
echo "Labels: $labels"
fi
done
As a follow-up, you could export with a one-liner:
docker ps -aq --format '{{.ID}}' | xargs -I {} docker inspect --format='{{.ID}}: {{.Config.Labels}}' {} | grep ': chadburn'
my bad, just a list of all runing jobs, including docker labels and chadburn config file
It can be seen in command line or logs for convenient task management