docker.recipes

httpbin

beginner

HTTP request and response service for testing.

Overview

HTTPBin is a simple HTTP request and response service created by Kenneth Reitz, designed specifically for testing HTTP libraries, REST APIs, and web services. Originally hosted at httpbin.org, this tool has become an essential utility for developers who need to debug HTTP requests, test webhooks, validate API clients, and understand how their applications handle various HTTP scenarios. HTTPBin returns detailed JSON responses containing all the information about incoming requests, including headers, parameters, form data, and cookies, making it invaluable for debugging and development workflows. This containerized HTTPBin deployment runs the official kennethreitz/httpbin Docker image, providing a local testing environment that eliminates dependencies on external services. The service operates on port 8080 and offers dozens of endpoints that simulate different HTTP scenarios, from basic GET/POST operations to complex authentication challenges, status code testing, and response delays. Unlike production APIs that might have rate limits or authentication requirements, HTTPBin provides unlimited access to test various HTTP behaviors in a controlled environment. Developers working on API integrations, QA engineers testing web applications, and DevOps teams validating monitoring systems will find this setup particularly valuable. HTTPBin's predictable responses and comprehensive endpoint coverage make it perfect for automated testing suites, webhook development, and HTTP client validation. The containerized approach ensures consistent behavior across different development environments while providing the flexibility to customize response scenarios without affecting other team members or external dependencies.

Key Features

  • Interactive HTML documentation interface accessible via web browser with live endpoint testing
  • Comprehensive HTTP method support including GET, POST, PUT, DELETE, PATCH with request echo functionality
  • Dynamic status code generation via /status/{code} endpoints for testing error handling scenarios
  • Configurable response delays through /delay/{seconds} endpoints for timeout and performance testing
  • Authentication testing endpoints supporting Basic Auth, Bearer tokens, and custom authentication schemes
  • Cookie manipulation endpoints for setting, retrieving, and deleting HTTP cookies during testing
  • Request inspection capabilities that return detailed JSON containing headers, query parameters, and body content
  • Response format flexibility supporting JSON, XML, HTML, and custom content types for various client testing needs

Common Use Cases

  • 1API client development and debugging when building applications that consume REST services
  • 2Webhook endpoint testing for services like GitHub, Stripe, or custom webhook implementations
  • 3HTTP library validation when developing or maintaining HTTP client libraries in various programming languages
  • 4Load testing preparation by using HTTPBin endpoints as reliable targets for performance testing tools
  • 5CI/CD pipeline integration testing where automated tests need predictable HTTP responses
  • 6Network proxy and load balancer configuration testing with consistent upstream responses
  • 7Educational purposes for teaching HTTP protocols, REST API concepts, and web service fundamentals

Prerequisites

  • Docker and Docker Compose installed on the host system
  • Port 8080 available and not conflicting with other local services
  • Minimum 64MB RAM allocation for the HTTPBin container
  • Basic understanding of HTTP methods and REST API concepts
  • Network access for pulling the kennethreitz/httpbin Docker image from Docker Hub
  • Web browser or HTTP client tool (curl, Postman, etc.) for interacting with endpoints

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 httpbin:
3 image: kennethreitz/httpbin:latest
4 container_name: httpbin
5 restart: unless-stopped
6 ports:
7 - "8080:80"

.env Template

.env
1# No configuration needed

Usage Notes

  1. 1Docs: https://httpbin.org/
  2. 2Access at http://localhost:8080 - interactive API documentation
  3. 3Test endpoints: /get, /post, /put, /delete, /headers, /cookies
  4. 4Returns request details as JSON (headers, args, body)
  5. 5Useful for testing HTTP clients, webhooks, and proxies
  6. 6Status codes: /status/{code}, delays: /delay/{seconds}

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 httpbin:
5 image: kennethreitz/httpbin:latest
6 container_name: httpbin
7 restart: unless-stopped
8 ports:
9 - "8080:80"
10EOF
11
12# 2. Create the .env file
13cat > .env << 'EOF'
14# No configuration needed
15EOF
16
17# 3. Start the services
18docker compose up -d
19
20# 4. View logs
21docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/httpbin/run | bash

Troubleshooting

  • Port 8080 already in use: Change the host port mapping to an available port like '8081:80' in the compose file
  • HTTPBin container exits immediately: Check Docker logs with 'docker logs httpbin' to identify startup issues or image pull problems
  • Cannot access web interface: Verify the container is running with 'docker ps' and confirm firewall rules allow localhost:8080 access
  • Slow response times on /delay endpoints: This is expected behavior - /delay/{seconds} endpoints intentionally introduce response delays
  • JSON parsing errors in responses: Ensure you're accessing the correct endpoints - HTML documentation is at root '/' while API endpoints start with specific paths like '/get' or '/post'
  • Authentication endpoints not working: Check that you're sending properly formatted Authorization headers - use '/basic-auth/{user}/{password}' format for testing basic authentication

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space