docker.recipes

Hastebin Pastebin

beginner

Simple pastebin alternative for sharing code snippets.

Overview

Hastebin is a minimalist, open-source pastebin service originally created by John Crepezzi that focuses on speed and simplicity for sharing code snippets and text. Unlike traditional pastebins that require forms and captchas, Hastebin provides an elegant interface where users can paste content directly and immediately receive a shareable URL, making it ideal for quick code sharing during development or debugging sessions. This implementation uses Redis as the backend storage engine, providing fast in-memory data access and built-in expiration capabilities that automatically clean up old pastes after 30 days. The combination of Haste Server and Redis creates a high-performance pastebin solution that can handle thousands of paste operations per second while maintaining data persistence through Redis's RDB snapshots. This stack is perfect for development teams, educational institutions, and organizations that need a private, self-hosted alternative to public pastebin services with complete control over data retention and access policies.

Key Features

  • Lightning-fast paste creation with immediate URL generation via Haste Server's streamlined interface
  • Automatic syntax highlighting for 150+ programming languages including JavaScript, Python, Go, and Rust
  • Built-in keyboard shortcuts (Ctrl+S to save, Ctrl+N for new paste) for rapid workflow integration
  • Redis-powered automatic paste expiration after 30 days to prevent storage bloat
  • RESTful API support for programmatic paste creation and retrieval
  • Command-line integration allowing direct piping of files and command output
  • Raw text viewing mode for easy copy-paste operations without formatting
  • Duplicate paste detection through Redis key management to optimize storage

Common Use Cases

  • 1Development teams sharing code snippets during pair programming and code reviews
  • 2Educational environments where instructors need to quickly share code examples with students
  • 3Internal corporate pastebin for sharing configuration files and scripts without external dependencies
  • 4DevOps teams sharing deployment scripts and configuration snippets during incident response
  • 5Open source projects providing a branded pastebin for community code sharing
  • 6Homelab enthusiasts running a personal pastebin for cross-device text and code synchronization
  • 7Organizations requiring GDPR compliance with full control over paste data storage and retention

Prerequisites

  • Docker and Docker Compose installed with at least 1GB available RAM for Redis operations
  • Port 7777 available for the Haste Server web interface and API access
  • Basic understanding of Redis data structures for troubleshooting storage issues
  • Approximately 512MB RAM allocated for Redis to handle concurrent paste operations effectively
  • Network access configured if planning to use the CLI haste-client tool from remote machines
  • Understanding of paste expiration policies to communicate data retention to users

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 hastebin:
3 image: ghcr.io/toptal/haste-server:latest
4 container_name: hastebin
5 environment:
6 - STORAGE_TYPE=redis
7 - STORAGE_HOST=redis
8 - STORAGE_PORT=6379
9 - STORAGE_EXPIRE_SECONDS=2592000
10 ports:
11 - "7777:7777"
12 depends_on:
13 - redis
14 networks:
15 - hastebin-network
16 restart: unless-stopped
17
18 redis:
19 image: redis:7-alpine
20 container_name: hastebin-redis
21 volumes:
22 - redis-data:/data
23 networks:
24 - hastebin-network
25 restart: unless-stopped
26
27volumes:
28 redis-data:
29
30networks:
31 hastebin-network:
32 driver: bridge

.env Template

.env
1# Hastebin
2# Default expiration: 30 days

Usage Notes

  1. 1Web UI at http://localhost:7777
  2. 2Paste code and get shareable link
  3. 3Keyboard shortcuts available
  4. 4Syntax highlighting
  5. 5CLI tool: cat file | haste

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

hastebin
hastebin:
  image: ghcr.io/toptal/haste-server:latest
  container_name: hastebin
  environment:
    - STORAGE_TYPE=redis
    - STORAGE_HOST=redis
    - STORAGE_PORT=6379
    - STORAGE_EXPIRE_SECONDS=2592000
  ports:
    - "7777:7777"
  depends_on:
    - redis
  networks:
    - hastebin-network
  restart: unless-stopped
redis
redis:
  image: redis:7-alpine
  container_name: hastebin-redis
  volumes:
    - redis-data:/data
  networks:
    - hastebin-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 hastebin:
5 image: ghcr.io/toptal/haste-server:latest
6 container_name: hastebin
7 environment:
8 - STORAGE_TYPE=redis
9 - STORAGE_HOST=redis
10 - STORAGE_PORT=6379
11 - STORAGE_EXPIRE_SECONDS=2592000
12 ports:
13 - "7777:7777"
14 depends_on:
15 - redis
16 networks:
17 - hastebin-network
18 restart: unless-stopped
19
20 redis:
21 image: redis:7-alpine
22 container_name: hastebin-redis
23 volumes:
24 - redis-data:/data
25 networks:
26 - hastebin-network
27 restart: unless-stopped
28
29volumes:
30 redis-data:
31
32networks:
33 hastebin-network:
34 driver: bridge
35EOF
36
37# 2. Create the .env file
38cat > .env << 'EOF'
39# Hastebin
40# Default expiration: 30 days
41EOF
42
43# 3. Start the services
44docker compose up -d
45
46# 4. View logs
47docker 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/hastebin-pastebin/run | bash

Troubleshooting

  • Pastes not saving or returning 500 errors: Check Redis container logs for memory issues and ensure STORAGE_HOST environment variable matches the Redis service name
  • Syntax highlighting not working for specific languages: Verify the paste content has proper file extensions or language hints, as Haste Server relies on content analysis for highlighting
  • CLI haste command timing out: Ensure the haste-client is configured with the correct server URL and that port 7777 is accessible from the client machine
  • Redis data persistence lost after container restart: Verify the redis-data volume is properly mounted and Redis has write permissions to /data directory
  • High memory usage in Redis container: Monitor paste creation rate and consider reducing STORAGE_EXPIRE_SECONDS or implementing Redis maxmemory policies for automatic eviction
  • Pastes expiring too quickly or not expiring: Verify STORAGE_EXPIRE_SECONDS is set correctly (2592000 = 30 days) and Redis is processing TTL commands properly

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