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

Healthcheck script #91

Open
kaznovac opened this issue Sep 21, 2023 · 7 comments
Open

Healthcheck script #91

kaznovac opened this issue Sep 21, 2023 · 7 comments

Comments

@kaznovac
Copy link

As a developer I'd like to have a way to issue a health check on memcached container without modifying the base image (base image has no telnet nor nc)

@LaurentGoderre
Copy link
Member

The following works on alpine:

echo "version" | nc -vn -w 1 127.0.0.1 11211

Source: https://book.hacktricks.xyz/network-services-pentesting/11211-memcache

@LaurentGoderre
Copy link
Member

And the following works on debian:

echo "version" | (exec 3<>/dev/tcp/localhost/11211; cat >&3; cat <&3; exec 3<&-)

@kaznovac
Copy link
Author

@LaurentGoderre Wow, thanks a lot, just what I've needed! (couldn't figure out the 'bidirectional' cat on my own)

I've added timeout to your debian command, so it will not block (just need to figure out the clean way to get the exit code)

echo "version" | (exec 3<>/dev/tcp/localhost/11211; cat >&3; timeout 0.1 cat <&3; exec 3<&-)

If it's ok with you I'd like to create PR to update the documentation of the image (later when I get some free time)

@LaurentGoderre
Copy link
Member

Absolutely! That would be awesome!

@tianon
Copy link
Member

tianon commented Dec 8, 2023

@LaurentGoderre
Copy link
Member

@tianon an example could be created here then: https://github.com/docker-library/healthcheck

@tianon
Copy link
Member

tianon commented Dec 13, 2023

Agreed! Does memcached have an explicit healthcheck type function we could use, or is just connecting the best we can do? For example, in SQL-based images, I've often used SELECT 1 as a basic health check because I can verify that the output of that query is exactly 1 to know that everything actually worked end-to-end (and it wasn't just something else accepting my connection and quietly doing nothing useful).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants