TIL: You can make HTTP requests without curl using Bash /dev/TCP
Points and comments are a snapshot, not live.
Bash's /dev/tcp can open raw TCP sockets for ad-hoc HTTP requests without curl.
The author needed to check connectivity between Docker containers where the Python image lacked curl or wget. Bash's /dev/tcp redirection opens a TCP socket, allowing a hand-crafted HTTP request via printf and cat. The trick requires `Connection: close` to prevent indefinite hangs. It only works for plain HTTP, not HTTPS, and is a bash-specific compile-time feature, not available in dash or zsh. The author emphasizes this is for quick debugging only, not a replacement for curl.
What commenters are saying
Commenters largely appreciated the trick for debugging minimal Docker images, but many pushed back on using it beyond ad-hoc tests. Several noted that Python images already include the socket and urllib modules, making `python3 -c 'from urllib.request import*;print(urlopen("http://example.com").status)'` a simpler and more portable approach. One thread debated the trade-offs of distroless images versus having debugging tools available, with some pointing to kubernetes ephemeral containers as a solution.