Skip to content
1 GB of residential proxies, free. $0 today, card required.
Surface separation runbook

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.

Docker → DatabayRegistry pulls and app routes are separate proxies
DockerContainer platform
Databay gateway modesClient support is covered below
gw.databay.co:8888
By Databay Research Team11 min runbook

Operating 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:

  1. Daemon proxy. dockerd uses it to reach registries and other swarm nodes, not to route container traffic.
  2. Client-injected variables. ~/.docker/config.json, docker run --env and --build-arg put HTTP_PROXY-style strings into containers and builds; each program decides whether to honor them.
  3. 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 controlDatabay valueWhat to verify
daemon.json proxies: http-proxy, https-proxy, no-proxyNormally none; it serves registry egressdocker pull works as intended
~/.docker/config.json proxies.default: httpProxy, httpsProxy, noProxyNone; every new container and build inherits it as plain textA throwaway container shows only expected variable names
docker build --build-argNone; keep builds off the paid routeNo credential in the Dockerfile or docker history
docker run --env HTTPS_PROXYAvoid credential-bearing values; use mounted secrets for the check belowNo password in the container configuration
Compose secretsUsername and password as separate filesReadable at /run/secrets/<secret_name>, no trailing newline
Application proxy settinggw.databay.co, 8888, complete dashboard username, passwordThe first request reports the expected exit
NO_PROXY or noProxyService names, localhost, 127.0.0.1, internal domainsInternal 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 ENV instruction embeds proxy settings in the image.
  • Predefined proxy build arguments stay out of docker history unless a matching ARG instruction 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.

  1. Pass the gateway address, gw.databay.co:8888, as ordinary configuration.
  2. Mount the username and password as secret files, using the *_FILE convention from Docker's Compose secrets guide: a variable holds a path under /run/secrets, not the value.
  3. 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_pass

Write 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_pass

Run 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-check

A 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 containerHop and layerNext safe check
Cannot resolve gw.databay.coProxy hop: DNSUser-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 8888Proxy hop: TCPCheck outbound firewall rules on the Docker host and its network.
407 Proxy Authentication RequiredProxy hop: authenticationLook 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 CONNECTProxy hop: scheme or tunnelUse http:// for the proxy value, not https://. Keep the refusal for support.
Internal calls fail or reach the gatewayRouting scopeAdd 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 opensDestination hop: TLSCompare the image's CA bundle and clock with the host's, and keep verification enabled.
Destination 401, 403 or 429Destination hop: HTTP statusStop 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

  1. Keep Databay values out of Dockerfile ENV, ARG, LABEL and RUN lines; .dockerignore keeps secret files out of the build context, so COPY cannot reach them.
  2. If a build truly needs a credential, use docker build --secret with RUN --mount=type=secret, mounted at /run/secrets/<id> by default. Builds should not need the Databay route.
  3. Never run docker commit on a container that received proxy credentials through its environment.
  4. Treat docker inspect output, docker compose config output (it shows interpolated values) and debug logs as sensitive; redact Proxy-Authorization and credential-bearing URLs, and never screenshot a visible password.
  5. 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.
  6. 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.

Troubleshooting desk

Questions specific to Docker

Does the Docker daemon proxy route my container traffic?
No. The proxy set in daemon.json or a systemd drop-in is what dockerd uses to reach registries and other swarm nodes. Container traffic follows the variables the Docker client injects or the proxy settings of the application inside the container.
How do I set a proxy for every Docker container?
Add a proxies block with a default key to ~/.docker/config.json. Docker then sets HTTP_PROXY, HTTPS_PROXY, NO_PROXY and their lowercase forms in new containers and builds. Use it for an unauthenticated egress proxy, not a Databay credential, because the values are stored as plain text in each container configuration.
Why does docker pull fail when my containers can reach the proxy?
Pulls are made by the daemon, not by your shell or your containers. Configure the daemon proxy in daemon.json or a systemd drop-in and restart Docker. Docker Desktop ignores daemon.json proxy settings, so use its own proxy settings there.
Is it safe to pass proxy credentials with --build-arg?
Avoid it. Docker leaves the predefined proxy build arguments out of docker history by default, but a matching ARG instruction puts them back, and Docker describes build arguments as inappropriate for secrets. Keep Databay credentials out of builds and use a build secret mount for any credential a build really needs.
Which NO_PROXY entries does a Docker Compose project need?
When proxy variables are present, list the service names your containers call, localhost, 127.0.0.1 and internal domains. Compose registers each service name in its internal DNS, so without those entries a client that honors HTTPS_PROXY can send internal calls to the gateway. Parsing varies by client, so test the one you ship.
Can a container use the Databay gateway over SOCKS5?
Yes, when the client library inside the container supports SOCKS5. The gateway accepts SOCKS5 on gw.databay.co port 8888, but Docker only passes the proxy string, so SOCKS support and whether the destination name is resolved locally or by the gateway depend on that client.
Adjacent runbooks

Same gateway, different control surface

  • cURL

    Command-line client

    curl -> proxy auth -> CONNECT or SOCKS -> approved destination

  • Python Requests

    HTTP client library

    Session -> HTTPAdapter policy -> proxy hop -> approved destination

  • Node.js fetch

    HTTP client library

    fetch -> env opt-in or same-package dispatcher -> proxy evidence

  • Android

    Mobile operating system

    Wi-Fi network -> Manual or PAC proxy -> app 407 prompt -> observed exit

  • Google Chrome

    Desktop browser

    --user-data-dir -> --proxy-server -> proxy sign-in -> 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.

Residential →Datacenter →

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.