Skip to content

DockBridge is a Go-based client-server system that provisions Hetzner Cloud servers for Docker containers, with laptop lock detection and keep-alive features. It enables seamless Docker workflows by proxying commands to remote Hetzner Cloud instances, managing server lifecycle by user activity and connection status.

License

Notifications You must be signed in to change notification settings

Max-Levitskiy/DockBridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

85 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ‰ DockBridge

Run Docker on cheap cloud servers, pay only when you use it

Why? β€’ Quick Start β€’ How it Works β€’ Features β€’ Configuration


The Problem

Docker Desktop on Mac/Windows is slow and resource-hungry. Running containers locally means:

  • 🐌 Slow builds on ARM Macs when targeting x86
  • πŸ”‹ Battery drain from VM overhead
  • πŸ’Ύ Precious SSD space consumed by images
  • πŸŒ€ Fans spinning when building large containers

Cloud dev environments are expensive. Keeping a cloud VM running 24/7:

  • πŸ’Έ ~$30-50/month for a decent dev server
  • πŸ”§ Manual setup and maintenance
  • πŸ“¦ Losing your containers when you forget to save

The Solution

DockBridge automatically provisions cloud servers that exist only when you need them.

# Point Docker at DockBridge
export DOCKER_HOST=unix:///tmp/dockbridge.sock

# Just use Docker normally - server spins up automatically
docker run hello-world   # Server created in ~60s
docker build .           # Fast x86 builds on x86 hardware

# Walk away - server auto-destroys when idle
# Your images and volumes persist on cheap cloud storage

Typical cost: $0.01-0.05/hour (only when actually building/running containers)

Why DockBridge?

Feature Local Docker Cloud VM DockBridge
Cost Free (but slow) $30-50/month Pay-per-use
Speed Slow on non-native arch Fast Fast
State persistence βœ… Manual βœ… Automatic
Resource usage High None local None local
Setup Easy Manual Easy

Quick Start

1. Install

# One-liner install (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/Max-Levitskiy/DockBridge/main/install.sh | sh
Other installation methods
# Build from source (requires Go 1.24+)
git clone https://github.com/Max-Levitskiy/DockBridge
cd dockbridge
go build -o dockbridge ./cmd/dockbridge
sudo mv dockbridge /usr/local/bin/

2. Configure

Create dockbridge.yaml:

hetzner:
  api_token: "your-hetzner-api-token"  # Get one at console.hetzner.cloud
  server_type: "cpx21"                  # 3 vCPU, 4GB RAM (~$0.01/hr)
  location: "fsn1"                      # Falkenstein, DE (or nbg1, hel1)
  volume_size: 10                       # Persistent storage in GB

docker:
  socket_path: "/tmp/dockbridge.sock"

ssh:
  key_path: "~/.ssh/id_rsa"            # Your SSH key

3. Use

# Start DockBridge
./dockbridge start

# In another terminal, point Docker at it
export DOCKER_HOST=unix:///tmp/dockbridge.sock

# Use Docker as usual
docker ps
docker run -it ubuntu bash
docker build -t myapp .

How it Works

Your Machine                              Hetzner Cloud
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚                     β”‚                  β”‚
β”‚  docker build .  β”‚                     β”‚   Docker Daemon  β”‚
β”‚        β”‚         β”‚                     β”‚        β–²         β”‚
β”‚        β–Ό         β”‚                     β”‚        β”‚         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚      SSH Tunnel     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ DockBridge │──┼─────────────────────┼─▢│   Docker   β”‚  β”‚
β”‚  β”‚            β”‚  β”‚    Encrypted        β”‚  β”‚   Socket   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚                     β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚        β–²         β”‚                     β”‚        β–²         β”‚
β”‚        β”‚         β”‚                     β”‚        β”‚         β”‚
β”‚  Unix Socket     β”‚                     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  /tmp/dockbridge β”‚                     β”‚  β”‚ Persistent β”‚  β”‚
β”‚                  β”‚                     β”‚  β”‚   Volume   β”‚  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”˜

1. You run `docker build`
2. DockBridge sees activity β†’ provisions server (if needed)
3. SSH tunnel forwards commands to remote Docker
4. Server auto-destroys after idle timeout
5. Volume persists your images & data

Features

πŸš€ Automatic Server Lifecycle

  • On-demand provisioning: Servers created when you run Docker commands
  • Auto-shutdown: Servers destroyed after configurable idle time
  • Instant resume: Volume persists, so images are still there next time

πŸ’Ύ Persistent Docker State

  • All images, containers, and volumes survive server destruction
  • Uses Hetzner's cheap block storage (~€0.04/GB/month)
  • No more "pulling all images again" on restart

πŸ”’ Secure by Default

  • All traffic encrypted via SSH tunnel
  • No exposed ports on cloud server
  • Uses your existing SSH keys

πŸ’° Cost Optimization

  • Pay only for compute time you use
  • Automatic idle detection
  • Real-time cost tracking with dockbridge status

Commands

# Start the proxy (required before using Docker)
dockbridge start [--daemon] [--socket /path/to/socket]

# Check current status, server info, and costs
dockbridge status [--json] [--watch]

# Stop and destroy the server
dockbridge stop [--force]

Configuration Reference

Setting Description Default
hetzner.api_token Hetzner Cloud API token Required
hetzner.server_type Server type (cpx11, cpx21, cpx31, etc.) cpx21
hetzner.location Datacenter (fsn1, nbg1, hel1, ash, hil) fsn1
hetzner.volume_size Persistent volume size in GB 10
docker.socket_path Local Unix socket path /tmp/dockbridge.sock
ssh.key_path Path to SSH private key ~/.ssh/id_rsa
ssh.timeout SSH connection timeout 10s

Hetzner Server Types

Type vCPU RAM Price/hr
cpx11 2 2GB ~$0.006
cpx21 3 4GB ~$0.010
cpx31 4 8GB ~$0.017
cpx41 8 16GB ~$0.033
cpx51 16 32GB ~$0.066

FAQ

Why Hetzner?

Hetzner offers the best price-to-performance ratio for cloud servers in Europe/US:

  • ~3x cheaper than AWS/GCP/Azure for equivalent specs
  • Excellent x86 performance for Docker builds
  • Simple, developer-friendly API
  • Block storage for persistent volumes

πŸ‘‰ Sign up for Hetzner Cloud and get €20 free credit to try DockBridge!

How does state persist when servers are destroyed?

DockBridge creates a persistent block volume that mounts at /var/lib/docker. When a server is destroyed, the volume remains. When a new server is provisioned, it reattaches the same volume, restoring all your images, containers, and volumes.

What about my running containers?

When the server is destroyed, running containers stop. On next use, the server is reprovisioned and you can restart your containers. Use docker-compose up -d or similar for easy restart.

Is it safe for production?

DockBridge is designed for development use. The auto-destroy feature means you shouldn't run production workloads. For production, use proper orchestration (Kubernetes, Docker Swarm, etc.).

Can I use a different cloud provider?

Currently only Hetzner is supported. AWS/GCP/Azure support is planned. PRs welcome!

Development

# Clone
git clone https://github.com/Max-Levitskiy/DockBridge
cd dockbridge

# Run tests
go test ./...

# Build
go build -o dockbridge ./cmd/dockbridge

# Run with debug logging
DOCKBRIDGE_DEBUG=1 ./dockbridge start

Contributing

Contributions are welcome! Please see our contributing guidelines.

Key areas for contribution:

  • Support for additional cloud providers (AWS, GCP, Azure)
  • Windows support
  • Improved idle detection
  • Cost prediction and alerts

License

AGPL-3.0 - See LICENSE


Built with β˜• for developers who want fast Docker builds without the VM overhead

About

DockBridge is a Go-based client-server system that provisions Hetzner Cloud servers for Docker containers, with laptop lock detection and keep-alive features. It enables seamless Docker workflows by proxying commands to remote Hetzner Cloud instances, managing server lifecycle by user activity and connection status.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages