Allow to use different DOCKER_HOST env var

This allows to use rootless podman (which doesn't require sudo) instead
of docker.
This commit is contained in:
Benjamin Neff 2022-12-05 00:53:33 +01:00
parent 2fe5a7bd40
commit 0c163b8c49
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -179,8 +179,10 @@ print_usage_full() {
# ----- Helper functions -----
dia_docker_compose() {
local docker_socket="${DOCKER_HOST:-"unix:///var/run/docker.sock"}"
docker_socket="${docker_socket#unix://}"
# Check permissions of docker socket and use sudo if needed
if [ -r "/var/run/docker.sock" ] && [ -w "/var/run/docker.sock" ]; then
if [ -r "${docker_socket}" ] && [ -w "${docker_socket}" ]; then
docker-compose "$@"
else
echo "Attention: Docker socket not writable, using sudo for the docker command. You might be asked for your password now." >&2