From 7cff8939f7b96ebec416a36c020a3f0c6cca8814 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Sat, 18 Jan 2025 17:41:34 +0100 Subject: [PATCH 1/3] fix: reverse docker socket test Fail if test -S $socket_file is false. Only display a warning if test -r $socket_file is false. --- app/entrypoint.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 5d9bab7b..09f24786 100755 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -14,16 +14,15 @@ function print_version { function check_docker_socket { if [[ $DOCKER_HOST == unix://* ]]; then socket_file=${DOCKER_HOST#unix://} - if [[ ! -r $socket_file ]]; then - echo "Error: Docker host socket at $socket_file is not readable. Please check user permissions" >&2 - echo "If you are in a SELinux environment, try using: '-v /var/run/docker.sock:$socket_file:z'" >&2 - exit 1 - fi - if [[ ! -S $socket_file ]]; then + if [[ ! -S $socket_file ]]; then echo "Error: you need to share your Docker host socket with a volume at $socket_file" >&2 echo "Typically you should run your container with: '-v /var/run/docker.sock:$socket_file:ro'" >&2 exit 1 fi + if [[ ! -r $socket_file ]]; then + echo "Warning: Docker host socket at $socket_file might not be readable. Please check user permissions" >&2 + echo "If you are in a SELinux environment, try using: '-v /var/run/docker.sock:$socket_file:z'" >&2 + fi fi } From 182b89c0b8d183fa409da18c60e719e93c400ff2 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Sat, 18 Jan 2025 17:45:02 +0100 Subject: [PATCH 2/3] refactor: whitespace typo --- app/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 09f24786..c0efb313 100755 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -14,7 +14,7 @@ function print_version { function check_docker_socket { if [[ $DOCKER_HOST == unix://* ]]; then socket_file=${DOCKER_HOST#unix://} - if [[ ! -S $socket_file ]]; then + if [[ ! -S $socket_file ]]; then echo "Error: you need to share your Docker host socket with a volume at $socket_file" >&2 echo "Typically you should run your container with: '-v /var/run/docker.sock:$socket_file:ro'" >&2 exit 1 From aa44e82d4a677d7d5b33505a07b1c423a30e7851 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Sat, 18 Jan 2025 19:57:07 +0100 Subject: [PATCH 3/3] fix: check -r only if -S check fail --- app/entrypoint.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index c0efb313..7f0c7a7a 100755 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -14,15 +14,15 @@ function print_version { function check_docker_socket { if [[ $DOCKER_HOST == unix://* ]]; then socket_file=${DOCKER_HOST#unix://} - if [[ ! -S $socket_file ]]; then + if [[ ! -S $socket_file ]]; then + if [[ ! -r $socket_file ]]; then + echo "Warning: Docker host socket at $socket_file might not be readable. Please check user permissions" >&2 + echo "If you are in a SELinux environment, try using: '-v /var/run/docker.sock:$socket_file:z'" >&2 + fi echo "Error: you need to share your Docker host socket with a volume at $socket_file" >&2 echo "Typically you should run your container with: '-v /var/run/docker.sock:$socket_file:ro'" >&2 exit 1 fi - if [[ ! -r $socket_file ]]; then - echo "Warning: Docker host socket at $socket_file might not be readable. Please check user permissions" >&2 - echo "If you are in a SELinux environment, try using: '-v /var/run/docker.sock:$socket_file:z'" >&2 - fi fi }