All Topics
All Topics
Technology
Technology
AI
AI
Business
Business
Entertainment
Entertainment
News
News
Programming
Programming
Security
Security
Science
Science
Design
Design
Environment
Environment
Finance
Finance
Crypto
Crypto
Politics
Politics
Sports
Sports
Education
Education
Gaming
Gaming
Art
Art
Music
Music
Health
Health
Books
Books
Food
Food
Travel
Travel
Personal
Personal
Bluesky
Twitter

How to make HTTP requests from a minimal Docker container using bash /dev/tcp

By

Marek Šuppa

18d ago· 3 min readen

Summary

A practical guide on making HTTP requests from minimal Docker containers that lack curl or wget. The solution uses bash's built-in /dev/tcp feature to open a TCP socket and manually write an HTTP/1.1 request, enabling health checks and connectivity testing between containers on a shared Docker network without installing additional tools.

Source

Hacker NewsHow to make HTTP requests from a minimal Docker container using bash /dev/tcpmareksuppa.com

Key quotes

· 3 pulled
bash can speak HTTP by itself bash can open a TCP socket, and you can write a small HTTP request to it by hand.
Opening a connection to a host and port and writing the request needs nothing beyond the shell that's already there.
The obvious move is curl http://service:8642/health. But this app image was stripped right down, with no curl or wget and nothing else around that I could use to open a socket.
Snippet from the RSS feed
Minimal container images often ship without curl, wget, or any HTTP client at all. Bash can open a TCP socket through /dev/tcp, which is enough to write a tiny HTTP/1.1 request by hand for quick checks.

You might also wanna read

Comments

Sign in to join the conversation.

No comments yet. Be the first.