Skip to content

Commit 3c87718

Browse files
authored
Get nginx container id from labelled container
1 parent 9c1a7b2 commit 3c87718

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ function get_nginx_proxy_cid {
3333
break
3434
fi
3535
done
36+
# Check if any container has been labelled as the nginx proxy container.
37+
local labeled_cid=$(docker_api "/containers/json" | jq -r '.[] | select( .Labels["jrcs.nginx_letsencrypt_companion.is_proxy"] == "true")|.Id')
38+
if [[ ! -z "${labeled_cid:-}" ]]; then
39+
export NGINX_PROXY_CONTAINER=$labeled_cid
40+
fi
3641
if [[ -z "${NGINX_PROXY_CONTAINER:-}" ]]; then
3742
echo "Error: can't get nginx-proxy container id !" >&2
38-
echo "Check that you use the --volumes-from option to mount volumes from the nginx-proxy." >&2
43+
echo "Check that you use the --volumes-from option to mount volumes from the nginx-proxy or label the nginx proxy container to use with 'jrcs.nginx_letsencrypt_companion.is_proxy=true'." >&2
3944
exit 1
4045
fi
4146
}

0 commit comments

Comments
 (0)