Docker Proxy Configuration: Daemon, Containers and Apps
Set the Docker daemon proxy for registry pulls, control variables injected into containers and builds, and route Databay through the app with secrets, in-container exit checks and 407 fixes.
gw.databay.co:8888Operating principle
Leave the daemon proxy to registry pulls and give only the application the authenticated Databay route, read from secrets at runtime.
Three Docker Proxy Surfaces, and Which One Carries Databay
"Docker proxy configuration" covers three settings that control different processes:
- Daemon proxy.
dockerduses it to reach registries and other swarm nodes, not to route container traffic. - Client-injected variables.
~/.docker/config.json,docker run --envand--build-argputHTTP_PROXY-style strings into containers and builds; each program decides whether to honor them. - Application configuration. The client inside the container is told which proxy and credential to use. The authenticated Databay route belongs here.
The Databay gateway, gw.databay.co:8888, serves HTTP proxying, HTTPS CONNECT tunnelling and SOCKS5, with no UDP. Traffic is billed per GB, so a route that also captures image pulls, package downloads or internal service calls wastes paid traffic. Scope it to the requests that need it, and use it only for destinations you own or are permitted to access, following each destination's terms.
Map Databay Values to Each Docker Control
Check each Docker control against this matrix before shipping.
| Docker control | Databay value | What to verify |
|---|---|---|
daemon.json proxies: http-proxy, https-proxy, no-proxy | Normally none; it serves registry egress | docker pull works as intended |
~/.docker/config.json proxies.default: httpProxy, httpsProxy, noProxy | None; every new container and build inherits it as plain text | A throwaway container shows only expected variable names |
docker build --build-arg | None; keep builds off the paid route | No credential in the Dockerfile or docker history |
docker run --env HTTPS_PROXY | Avoid credential-bearing values; use mounted secrets for the check below | No password in the container configuration |
Compose secrets | Username and password as separate files | Readable at /run/secrets/<secret_name>, no trailing newline |
| Application proxy setting | gw.databay.co, 8888, complete dashboard username, password | The first request reports the expected exit |
NO_PROXY or noProxy | Service names, localhost, 127.0.0.1, internal domains | Internal calls never reach the gateway |
Daemon Proxy: daemon.json, systemd and Docker Desktop
The daemon proxy governs dockerd's own connections to registries and swarm nodes. Docker recommends the proxies object in daemon.json, followed by sudo systemctl restart docker:
{
"proxies": {
"http-proxy": "http://egress.corp.example:3128",
"https-proxy": "http://egress.corp.example:3128",
"no-proxy": "registry.internal.example,127.0.0.0/8"
}
}A systemd drop-in at /etc/systemd/system/docker.service.d/http-proxy.conf also works: set HTTP_PROXY, HTTPS_PROXY and NO_PROXY in Environment= lines under [Service], write each % of a percent-encoded value as %%, run sudo systemctl daemon-reload, restart Docker, and confirm with sudo systemctl show --property=Environment docker. Configuring the daemon directly takes precedence over those variables. Rootless mode uses ~/.config/systemd/user/docker.service.d/ and systemctl --user.
Docker Desktop ignores daemon.json proxy settings; its Resources > Proxies settings split a Docker Desktop proxy for host-level traffic, such as signing in and the CLI, from a Containers proxy for image pulls that covers outbound container traffic only under air-gapped container enforcement. A Databay credential in any of these places would bill registry pulls without routing your application.
Client-Injected Variables: config.json, --env and --build-arg
In ~/.docker/config.json, the default key applies to every daemon the client uses; a daemon address as the key scopes the settings to that daemon:
{
"proxies": {
"default": {
"httpProxy": "http://egress.corp.example:3128",
"httpsProxy": "http://egress.corp.example:3128",
"noProxy": "localhost,127.0.0.1,api,db,.internal.example"
}
}
}Docker maps httpProxy, httpsProxy, noProxy, ftpProxy and allProxy to uppercase and lowercase variables and build arguments for containers and builds only, not the CLI or Engine; saved changes apply without a restart to new containers and builds. docker run --env and docker build --build-arg set the same names per command, with the same exposure. Docker's cautions explain why no credential belongs here:
- Environment variables are stored as plain text in the container's configuration, can be inspected through the remote API, and are committed into an image by
docker commit. - The Dockerfile
ENVinstruction embeds proxy settings in the image. - Predefined proxy build arguments stay out of
docker historyunless a matchingARGinstruction preserves them, and Docker calls build arguments inappropriate for secrets.
A global setting also offers the paid route to package managers in every build. For Databay, an HTTPS_PROXY value still starts with http://: the variable name picks which destinations use the proxy, and HTTPS destinations are tunnelled with CONNECT.
Configure the Authenticated Route Inside the Application
Only the application knows which requests need an external exit. Configured there, the route covers just those requests and the image holds nothing about Databay.
- Pass the gateway address,
gw.databay.co:8888, as ordinary configuration. - Mount the username and password as secret files, using the
*_FILEconvention from Docker's Compose secrets guide: a variable holds a path under/run/secrets, not the value. - At startup, read each file, strip any trailing newline, and pass the values to the client's own proxy setting, as the Python Requests, Node.js fetch and cURL guides show. Never log the result.
Choose the product and routing in the dashboard, then copy the complete username, such as USER-zone-residential-countryCode-us, instead of assembling flags from memory. Premium Residential targets one of country, state, city, ZIP, coordinate or ASN at a time; Residential Flex, Datacenter and Mobile target country or continent. A sticky session adds a segment such as -sessionId-abc123 and requests continuity for up to 1440 minutes on Premium Residential and Residential Flex where available, or up to 120 minutes on Datacenter and Mobile. The IP can change before the window ends. All pools are shared: a new proxy connection may select an available exit and a reused connection may retain one, so jobs should tolerate either.
A Compose File That Keeps the Credential in Secrets
One service receives the credential as two secret files, and an on-demand check shares its default network. The example/collector:1.4.2 image is a placeholder for your own application, which must implement the *_FILE reads described above.
services:
collector:
image: example/collector:1.4.2
environment:
DATABAY_PROXY_ADDR: "gw.databay.co:8888"
DATABAY_PROXY_USER_FILE: /run/secrets/databay_proxy_user
DATABAY_PROXY_PASS_FILE: /run/secrets/databay_proxy_pass
secrets:
- databay_proxy_user
- databay_proxy_pass
exit-check:
image: curlimages/curl:8.23.0
user: "0:0" # one-shot check can read owner-only file secrets
profiles: ["verify"]
command: ["--disable", "--proxy", "http://gw.databay.co:8888", "--noproxy", "",
"--variable", "databay_user@/run/secrets/databay_proxy_user",
"--variable", "databay_pass@/run/secrets/databay_proxy_pass",
"--expand-proxy-user", "{{databay_user:url}}:{{databay_pass:url}}",
"--silent", "--show-error", "--max-time", "20",
"https://api.ipify.org?format=json"]
secrets:
- databay_proxy_user
- databay_proxy_pass
secrets:
databay_proxy_user:
file: ./secrets/databay_proxy_user
databay_proxy_pass:
file: ./secrets/databay_proxy_passWrite the files from your secret manager's variables without trailing newlines, and list secrets/ in .gitignore and .dockerignore:
umask 077
mkdir -p secrets
printf '%s' "$DATABAY_PROXY_USER" > secrets/databay_proxy_user
printf '%s' "$DATABAY_PROXY_PASS" > secrets/databay_proxy_passRun docker compose run --rm exit-check; targeting a profiled service runs it, while docker compose up skips it. cURL 8.3 and later can import files into variables and expand them inside an option. The pinned image supports this: the username and password are read inside cURL rather than inserted into a URL, command line or quoted config file, with the url function encoding each part before libcurl decodes the proxy credential. This preserves literal percent signs, quotes and backslashes. --disable skips its default config file and --noproxy "" prevents inherited exclusions from bypassing the gateway.
Compose bind-mounts file-based secrets and ignores uid, gid and mode for them, so host file permissions decide whether the container user can read them. The one-shot cURL service runs as container root to read the private files; give your application only the file access its configured user needs. Compose also interpolates $ in the Compose file ($$ is a literal dollar sign) and in unquoted or double-quoted env_file values; single quotes keep a value literal.
Reserve env_file for applications that read only environment variables: Docker advises against passing passwords that way, and the values land in the container's configuration.
Verify the Exit From Inside a Container Before Real Work
Observe the exit on a harmless endpoint before any real destination, from the workload's network. Docker may inject both uppercase and lowercase proxy variables from the client configuration, so an ordinary docker run is not a direct control by itself. The baseline explicitly disables proxy use, while the Compose check selects the gateway and overrides inherited NO_PROXY exclusions.
# Proxy variable names injected by the client
docker run --rm alpine sh -c 'env | grep -i _proxy | cut -d= -f1'
# Direct baseline: ignore client-injected proxy variables and default cURL config
docker run --rm curlimages/curl:8.23.0 --disable --proxy "" \
--silent --show-error --max-time 20 "https://api.ipify.org?format=json"
# Proxied check: read mounted secrets with an explicit proxy and no bypass
docker compose run --rm exit-checkA proxied result equal to the baseline means the expected route was not demonstrated; inspect the effective client configuration before continuing. For a second observer, use https://databay.com/what-is-my-ip/json, explained on the What Is My IP page. Then have the application's first request reach that endpoint through its own client, logging only the address, image tag and UTC time. An observed IP is point-in-time evidence, not proof of anonymity; re-check sticky sessions at your job's checkpoints.
Ready to run this for real?
Credentials appear in your dashboard in minutes, on the same gateway and username format this Docker guide uses.
Troubleshoot Proxy-Hop and Destination-Hop Failures
Find the first failing layer before changing anything. Proxy-hop failures occur between the container and gw.databay.co:8888; destination-hop failures occur after the gateway accepts the request or tunnel.
| Evidence in the container | Hop and layer | Next safe check |
|---|---|---|
Cannot resolve gw.databay.co | Proxy hop: DNS | User-defined networks such as Compose's default use Docker's embedded DNS at 127.0.0.11, which forwards to the host's resolvers; the default bridge copies the host's /etc/resolv.conf. Compare host and container lookups before adding --dns. |
| Refused or timed-out connection to port 8888 | Proxy hop: TCP | Check outbound firewall rules on the Docker host and its network. |
| 407 Proxy Authentication Required | Proxy hop: authentication | Look for a trailing newline in a secret file, empty shell variables, missing percent-encoding or Compose interpolation of $. Re-copy the complete dashboard username. |
| TLS error at the gateway, or a refused CONNECT | Proxy hop: scheme or tunnel | Use http:// for the proxy value, not https://. Keep the refusal for support. |
| Internal calls fail or reach the gateway | Routing scope | Add service names, localhost and internal domains to NO_PROXY; Docker notes that no standard defines how clients handle it, so test your client. |
| Certificate error after the tunnel opens | Destination hop: TLS | Compare the image's CA bundle and clock with the host's, and keep verification enabled. |
| Destination 401, 403 or 429 | Destination hop: HTTP status | Stop and resolve access through the destination's supported process; another exit is not permission. |
SOCKS5 depends on the client library inside the container: the gateway accepts it on the same host and port, but Docker only passes the ALL_PROXY string, so socks5:// or socks5h:// works only if that client implements SOCKS5. The HTTP versus SOCKS5 comparison covers who resolves the destination name.
Credential Hygiene for Dockerfiles, Layers and Logs
- Keep Databay values out of Dockerfile
ENV,ARG,LABELandRUNlines;.dockerignorekeeps secret files out of the build context, soCOPYcannot reach them. - If a build truly needs a credential, use
docker build --secretwithRUN --mount=type=secret, mounted at/run/secrets/<id>by default. Builds should not need the Databay route. - Never run
docker commiton a container that received proxy credentials through its environment. - Treat
docker inspectoutput,docker compose configoutput (it shows interpolated values) and debug logs as sensitive; redactProxy-Authorizationand credential-bearing URLs, and never screenshot a visible password. - Source secret files from a secret manager. On Swarm, Docker secrets serve only swarm services, are encrypted in transit and at rest, and mount in an in-memory filesystem.
- After any exposure, rotate the credential in the dashboard, replace the files and recreate the containers.
Compare networks on the proxy product hub once the in-container check matches the requested route.
Questions specific to Docker
Does the Docker daemon proxy route my container traffic?
How do I set a proxy for every Docker container?
Why does docker pull fail when my containers can reach the proxy?
Is it safe to pass proxy credentials with --build-arg?
Which NO_PROXY entries does a Docker Compose project need?
Can a container use the Databay gateway over SOCKS5?
Same gateway, different control surface
Python Requests
HTTP client library
Session -> HTTPAdapter policy -> proxy hop -> approved destination
Android
Mobile operating system
Wi-Fi network -> Manual or PAC proxy -> app 407 prompt -> observed exit
.NET HttpClient
HTTP client library
HttpClient -> SocketsHttpHandler.Proxy -> CONNECT or SOCKS5 -> observed exit
Pick the network once the route works. Residential for home-connection exits with state, city, ZIP and ASN targeting; datacenter for fast server IPs on public websites. Switching is one word in the username.
Where teams run Docker behind the gateway: Proxies for web scraping · Proxies for website monitoring
Ship Docker to production
Create an account, drop in your gateway credentials, and route your first Docker request in minutes.
Pricing, order minimums, and traffic validity vary by product.