Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reverse docker socket test #1182

Merged
merged 3 commits into from
Jan 19, 2025
Merged

fix: reverse docker socket test #1182

merged 3 commits into from
Jan 19, 2025

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented Jan 18, 2025

Fix proposed by @andrei-datcu for #1179

The entrypoint will fail if test -S $socket_file is false but only display a warning if test -r $socket_file is false.

Fail if test -S $socket_file is false.
Only display a warning if test -r $socket_file is false.
@buchdag buchdag added the type/fix PR for a bug fix label Jan 18, 2025
@buchdag buchdag self-assigned this Jan 18, 2025
@buchdag buchdag linked an issue Jan 18, 2025 that may be closed by this pull request
app/entrypoint.sh Outdated Show resolved Hide resolved
@andrei-datcu
Copy link

I don't have the proper historical context of why the -r check was introduced, but for the original problem the check tried to resolve would this change work or would the -S check fail before -r test would get a chance to run? I was thinking the -r check would only be done if the -S failed to try and output a more explicit error message.

@buchdag
Copy link
Member Author

buchdag commented Jan 18, 2025

The -r check was added here #1149

So maybe something like this instead ?

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

@andrei-datcu
Copy link

Yes, that looks better to me.

@buchdag buchdag marked this pull request as ready for review January 18, 2025 18:57
@buchdag
Copy link
Member Author

buchdag commented Jan 18, 2025

Done, pushed as nginxproxy/acme-companion:1182 if you wish to try it before we merge this.

@andrei-datcu
Copy link

I've just tested it and it's working nicely. Thank you! :)

@buchdag buchdag merged commit f47ced8 into main Jan 19, 2025
36 checks passed
@buchdag buchdag deleted the fix/1179 branch January 19, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix PR for a bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Docker host socket at /var/run/docker.sock is not readable
2 participants