[CI] Avoid docker login if docker is not running (#183379)

## Summary
We've found that the command tries to log in to docker in cases when the
`docker` binary is available (installed) but not running on the devices.
This can happen, for example, on a device that's set up a bit
differently than our normal CI executors (e.g.: [bare metal
executors](https://buildkite.com/elastic/kibana-single-user-performance/builds/13383)).

This PR makes it sure that we only interact with docker in that step, if
it's running.
This commit is contained in:
Alex Szabo 2024-05-14 14:09:38 +02:00 committed by GitHub
parent c4f08c0ce9
commit 9d1a37d2db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,7 +21,7 @@ fi
KIBANA_DOCKER_USERNAME="$(vault_get container-registry username)"
KIBANA_DOCKER_PASSWORD="$(vault_get container-registry password)"
if command -v docker &> /dev/null; then
if (command -v docker && docker version) &> /dev/null; then
echo "$KIBANA_DOCKER_PASSWORD" | docker login -u "$KIBANA_DOCKER_USERNAME" --password-stdin docker.elastic.co
fi
}