use env instead of labels

This commit is contained in:
Chai Feng 2018-10-03 10:33:43 +08:00
parent aa020f4462
commit 6001834bab
No known key found for this signature in database
GPG Key ID: 2DCD9A24E523FFD2

View File

@ -143,17 +143,20 @@ function ufw-docker--service-allow() {
return 1 return 1
fi fi
service_label="ufw.public.${service_name}=${service_port}" service_env="ufw_public_${service_name}=${service_port:-all}"
if ! docker service inspect "$ufw_docker_agent" &>/dev/null; then if ! docker service inspect "$ufw_docker_agent" &>/dev/null; then
err "Not found ufw-docker-agent service, creating ..." err "Not found ufw-docker-agent service, creating ..."
docker service create --name "$ufw_docker_agent" --mode global \ docker service create --name "$ufw_docker_agent" --mode global \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--mount type=bind,source=/etc/ufw,target=/etc/ufw,readonly=true \ --mount type=bind,source=/etc/ufw,target=/etc/ufw,readonly=true \
--label "${service_label}" \ --env "${service_env}" \
"${ufw_docker_agent_image}" "${ufw_docker_agent_image}"
else else
docker service update --update-parallelism=0 --label-add "${service_label}" "${ufw_docker_agent}" docker service update --update-parallelism=0 \
--env-add "${service_env}" \
--image "${ufw_docker_agent_image}" \
"${ufw_docker_agent}"
fi fi
} }