Static IP and tunnels in Docker
Connect Docker containers to allowlisted APIs from a fixed IPv4 and accept inbound tunnels in Compose without changing host routing.
First payment refunded within 7 days if it doesn’t work for you
- Partner API
- External DB
On this page14
Containers inherit the host’s outbound IP — which shifts whenever a VM is replaced or scaled — and normally require published host ports for inbound access. In Docker Compose, Prontaro covers both cases with two setups: proxy environment variables for HTTP traffic, or a lightweight prontaro sidecar for TCP forwarding and inbound tunnels.
Which method to choose
| Method | What it solves | Extra container needed |
|---|---|---|
1. PRONTARO_PROXY_URL + NO_PROXY |
Outbound HTTP/HTTPS and socks5h:// calls from your dedicated IPv4 |
No |
2A. Sidecar prontaro forward |
Outbound TCP to allowlisted databases and SFTP when the driver has no SOCKS5 support | Yes (--listen 0.0.0.0 on Compose network, or network_mode: "service:app") |
2B. Sidecar prontaro http / tcp |
Inbound HTTPS or TCP tunnel to a container without publishing host ports | Yes (on the Compose network) |
Prerequisites
- For static IPv4, proxy, and
prontaro forward: Dedicated (from $12/mo, 100 GB traffic) or Pro (plans). - For inbound
prontaro http: any plan (*.prontaro.devon Free,*.prontaro.runon paid plans); forprontaro tcp: Tunnels ($6/mo) or higher. - Docker Engine and Docker Compose v2 (
docker compose).
Method 1. Outbound proxy (PRONTARO_PROXY_URL + NO_PROXY)
Best for backend containers calling allowlisted REST/GraphQL APIs.
Step 1. Create proxy credentials
Add your dedicated IPv4 (/32) to the partner API allowlist and create proxy credentials in the dashboard. Leave the To destination list open until you verify the IP.
- Open IP addresses in my.prontaro.com and click Create proxy credentials.
- Name them
docker-appand copy theHTTPSURL (port:443).
Step 2. Configure compose.yml and exclude internal networks
Store credentials in .env (keep .env in .gitignore and never bake secrets into a Dockerfile):
# .env
PRONTARO_PROXY_URL=https://u_docker:s3cr3t@<entry>.prontaro.io:443If your code explicitly passes PRONTARO_PROXY_URL only to the external API client, no global proxy variable is needed. If an app or tool reads standard HTTPS_PROXY / HTTP_PROXY, always set NO_PROXY to exclude Docker Compose service names and private ranges:
# compose.yml
services:
app:
build: .
env_file: .env
environment:
# Preferred: pass explicitly only to external API clients
PRONTARO_PROXY_URL: ${PRONTARO_PROXY_URL}
# If using global proxy env vars, exclude internal services and RFC 1918:
HTTPS_PROXY: ${PRONTARO_PROXY_URL}
HTTP_PROXY: ${PRONTARO_PROXY_URL}
NO_PROXY: localhost,127.0.0.1,postgres,redis,.local,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
depends_on:
- postgres
- redis
postgres:
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: dev-only-password
redis:
image: redis:7-alpineStep 3. Verify the outbound IP
Start the stack and check the outbound IP from inside the container before restricting allowed destinations:
docker compose up -d && docker compose exec app curl -fsS --proxy "$PRONTARO_PROXY_URL" https://api.ipify.org
203.0.113.10Step 4. Lock down allowed hosts and ports
After verification, restrict docker-app to the exact partner hosts and ports:
- Open IP addresses → Proxy credentials in my.prontaro.com, select
docker-app, open the Access tab, and addapi.example.com:443under To. - Save.
Method 2. Sidecar container prontaro with PRONTARO_KEY
When a container needs outbound TCP port forwarding (prontaro forward) or an inbound tunnel (prontaro http / prontaro tcp), build a tiny sidecar image with the prontaro binary and authenticate it via PRONTARO_KEY.
Build Dockerfile.prontaro
Running install.sh as root installs prontaro directly into /usr/local/bin/prontaro:
# Dockerfile.prontaro
FROM alpine:3.20
RUN apk add --no-cache ca-certificates curl \
&& curl -fsSL https://prontaro.com/install.sh | sh
ENTRYPOINT ["prontaro"]When PRONTARO_KEY is set, prontaro works even in read-only containers (read_only: true) without a writable state directory or $HOME (ephemeral in-memory state). If you want offline cache persistence across restarts, also mount a /state volume and set PRONTARO_STATE_DIR=/state.
Issue a dedicated CLI token in my.prontaro.com and save it in .env as PRONTARO_KEY:
- Open the CLI page in my.prontaro.com and create a token named
docker-sidecar. - Put it in
.env:PRONTARO_KEY=<token>.prontaro CLIreadsPRONTARO_KEYdirectly from the environment — noprontaro logincommand is needed on container startup.
Option 2A. Outbound TCP forwarding (prontaro forward)
By default prontaro forward binds to 127.0.0.1:<port>. In Docker Compose, pass --listen 0.0.0.0 so sibling containers on the private Compose network can reach prontaro-forward:15432 (or attach the sidecar via network_mode: "service:app" to keep it on 127.0.0.1:15432). Pass --no-input so the process never prompts, and configure restart: unless-stopped (or --restart unless-stopped with docker run): on startup refusals (such as an unpaid or blocked account), prontaro exits with a non-zero code instead of waiting, and Docker restarts the container automatically with backoff until it comes up:
# compose.yml
services:
app:
build: .
environment:
DATABASE_URL: postgres://app:secret@prontaro-forward:15432/prod?sslmode=require
depends_on:
- prontaro-forward
prontaro-forward:
build:
context: .
dockerfile: Dockerfile.prontaro
read_only: true
environment:
PRONTARO_KEY: ${PRONTARO_KEY}
command: ["forward", "15432", "db.example.com:5432", "--listen", "0.0.0.0", "--ip", "203.0.113.10", "--no-input", "--json"]
restart: unless-stoppedOption 2B. Inbound tunnels (prontaro http and prontaro tcp)
For inbound traffic, run the sidecar on the normal Compose bridge network and target sibling containers by service name (app:3000 or postgres:5432). Keep --no-input paired with restart: unless-stopped (or --restart unless-stopped in docker run) so Docker retries startup refusals automatically (once running, tunnels wait and recover on their own):
# compose.yml
services:
app:
build: .
# No host ports need to be published
postgres:
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
prontaro-http:
build:
context: .
dockerfile: Dockerfile.prontaro
environment:
PRONTARO_KEY: ${PRONTARO_KEY}
PRONTARO_STATE_DIR: /state
volumes:
- prontaro_http_state:/state
command: ["http", "app:3000", "--name", "staging-web", "--no-input", "--json"]
restart: unless-stopped
prontaro-tcp:
build:
context: .
dockerfile: Dockerfile.prontaro
environment:
PRONTARO_KEY: ${PRONTARO_KEY}
PRONTARO_STATE_DIR: /state
volumes:
- prontaro_tcp_state:/state
command: ["tcp", "postgres:5432", "--name", "staging-pg", "--to", "203.0.113.10", "--no-input", "--json"]
restart: unless-stopped
volumes:
prontaro_http_state:
prontaro_tcp_state:New TCP tunnels start closed to everyone — after starting the container, open access only to trusted IPs:
- Open Tunnels in my.prontaro.com, select
staging-pg, and switch to the Access tab. - Add the allowed IPv4 address or CIDR and click Save.
docker compose exec prontaro-tcp prontaro access staging-pg allow 198.51.100.7Docker notes and limits
- Never bake secrets into images: pass
PRONTARO_PROXY_URLandPRONTARO_KEYvia runtimeenv_fileor Docker Secrets, neverDockerfileENVorARG. - Use
--jsonfor logs: pass--jsonto sidecar commands (forward,http,tcp) so Docker log drivers and log aggregators receive structured JSON lines. - One state volume per sidecar: if you run both
prontaro-httpandprontaro-tcp, give each sidecar its own/statevolume. - Choose a nearby IP location: pick the Prontaro location in the dashboard closest to your hosts and target APIs.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
403 destination_denied when calling postgres or redis |
Internal container hostnames are missing from NO_PROXY. |
Add service names and 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 to NO_PROXY. |
Connection refused on prontaro-forward:15432 from app |
prontaro forward is listening on 127.0.0.1 instead of 0.0.0.0, or not sharing app’s network namespace. |
Pass --listen 0.0.0.0 (on a private Compose network) or set network_mode: "service:app". |
407 Proxy Authentication Required |
Wrong password in .env, or newly created credentials are still propagating. |
Copy the exact URL under IP addresses, update .env, and run docker compose up -d. |
You have 2 addresses — choose which one |
Pro account has multiple IPs and --ip was omitted. |
Pass --ip <your-IP> in the sidecar command:. |
Next steps
- PostgreSQL and AWS RDS with a static IP — connect to allowlisted cloud databases over
prontaro forwardorsocks5h://and expose private databases. - Static IP for Fly.io — configure outbound proxies and
prontaro forwardin Fly.io container apps. - Local port forwarding (
prontaro forward) — full reference for outbound TCP forwarding to databases and SFTP servers. - TCP tunnels — accept inbound TCP connections on your dedicated IPv4 with IP allowlists.
Related guides
- HTTP & SOCKS5 proxyRoute outbound HTTP, HTTPS, and TCP connections through your static IPv4 with one proxy credential set, end-to-end TLS, and From/To rules.
- Relay URLsCall IP-allowlisted HTTPS APIs from edge runtimes and no-code tools without proxy configuration by replacing the base URL with a Prontaro Relay URL.
- Local port forwarding (prontaro forward)Connect database drivers, SFTP clients, and CLI tools to remote servers from your static IPv4 over a local TCP port — no proxy support needed.
Something wrong on this page? Contact us