I was reading the elasticsearch documentation on Elastic Stack on Docker with TLS.
I came across this line in the healthcheck block:
curl --cacert $CERT_PATH/ca/ca.crt -s https://localhost:9200 >/dev/null
if [[ $$? == 52 ]]; then
echo 0
else
echo 1
fi
The script uses the CA cert in the specified directory to verify the peer.
I know that $?
is the exit status of the most recent foreground pipeline (curl in this case). My question is why are there 2 $
in the [[...]]
test command construct. I tried removing the 1 $
, but then Docker complains about an invalid interpolation format for the health check option ...
Does the 1st $
serve some specific purpose in docker-compose files or is $$?
in itself some special shell variables?
Link to the full docker-compose.yml on elastic's Github repo. The above line corresponds to line 38 in the linked docker-compose.yml.