#!/bin/bash export DOCKER_HOST=tcp://dev-iru-swarm.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1 docker service ps bind --format "{{.Node}} {{.DesiredState}}" | while read host status do if [ ${status} == Running ] then export DOCKER_HOST=tcp://${host}:2376 DOCKER_TLS_VERIFY=1 container_id=$(docker ps|grep bind|awk '{print $1}') echo ${container_id} docker cp ${container_id}:/var/bind/infoclinica . fi done scp -r infoclinica ns41.infoclinica.lan:/var/named rm -rf infoclinica ssh ns41.infoclinica.lan 'systemctl restart named'