ping from a container without ping installed

Troubleshooting docker network issues can be a bit tricky, especially if your container is minimal (as it should be). If you don’t want to install ping then you can do the following:

(echo >/dev/tcp/{HOST}/{PORT}) &>/dev/null && echo "open" || echo "closed"

If you can’t connect with the hostname, remember to try with a FQDN or an IP to rule out DNS issues.

Pretty fancy!

By Sam

Drupal developer from Perth, Western Australia. I love programming, gaming, the Internet, growing vegetables and hiking.

Leave a comment

Your email address will not be published. Required fields are marked *