How to set up a proxy in Docker (Containers, Compose & Builds)

Updated:

When running multi-container scrapers, automation workers, or DePIN nodes on a single host server, passing HTTP_PROXY and HTTPS_PROXY environment variables per container lets each service exit through its own dedicated static IPv4 address from VinaProxy without altering the host machine's routing table.

Docker · HTTP Proxy Format
ENV HTTP_PROXY=http://user:pass@ip:port HTTPS_PROXY=http://user:pass@ip:port
Private IPv4 (datacenter)
🇸🇬 Singapore
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy Singapore
Private IPv4 (datacenter)
🇺🇸 United States
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy United States

Understanding the 3 Docker proxy configuration scopes

Docker separates container runtime traffic, image build traffic, and daemon registry pulls:

Docker ScopeWhere to ConfigureWhat It Routes
1. Container Runtimedocker run -e HTTP_PROXY=... or Compose environment:Traffic generated by the app inside that specific container
2. Image Build (docker build)--build-arg HTTP_PROXY=http://user:pass@ip:portPackage manager downloads (apt, pip, npm) during build
3. Docker Daemon (dockerd)/etc/systemd/system/docker.service.d/http-proxy.confdocker pull and docker push requests to registries

Docker Compose best practices & NO_PROXY rules

  • Set both uppercase (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) and lowercase (http_proxy, https_proxy, no_proxy) variables so all Linux CLI tools and language runtimes pick them up
  • Always list internal Docker Compose service names (e.g., NO_PROXY=localhost,127.0.0.1,redis,postgres) so inter-container traffic stays on the local bridge network
  • Never bake proxy passwords into public images with ENV inside a Dockerfile—inject them at runtime via .env or docker-compose.yml

Step by step

  1. 1

    Format your proxy as http://user:pass@ip:port

    Convert your VinaProxy ip:port:user:pass line using our Proxy Format Converter.

  2. 2

    Add environment variables to docker-compose.yml

    Under your service's environment:, define HTTP_PROXY, HTTPS_PROXY, http_proxy, https_proxy, and NO_PROXY=localhost,127.0.0.1,redis,db.

  3. 3

    Start or recreate the container

    Run docker compose up -d to apply the environment variables.

  4. 4

    Verify exit IP from inside the container

    Execute docker exec -it <container> curl -s https://vinaproxy.com/api/my-ip to confirm the container exits through your proxy IP.

Frequently asked questions

Why can't my container reach my Redis or Postgres container after setting HTTP_PROXY?

Without NO_PROXY, your HTTP client tries to reach internal service names like redis or db through the external proxy. Add NO_PROXY=localhost,127.0.0.1,redis,db (and lowercase no_proxy) to bypass the proxy for internal bridge hosts.

Can I assign 20 different proxies to 20 containers on one VPS?

Yes. Define each container service (or pass distinct .env variables) with its own http://user:pass@ip:port string.

Why set both uppercase and lowercase proxy variables?

Some Linux libraries (like libcurl) check lowercase http_proxy / https_proxy first, while Go and Node tools often check uppercase HTTP_PROXY / HTTPS_PROXY.

Assign dedicated static IPs to every Docker container

Instant unmetered Dedicated IPv4 and Static ISP proxies across 7 countries.

Buy Docker Proxies

Related articles

Proxy setup
How to Configure Proxy on Ubuntu & Debian Linux
Configure VinaProxy HTTP(S) proxies on Ubuntu Server and Desktop across /etc/environment, APT package manager, systemd daemons, and GNOME Network settings.
Proxy setup
How to use a proxy with cURL (command-line syntax & debugging)
How to use curl with authenticated HTTP(S) proxies (-x http://user:pass@ip:port and -U) on Linux, macOS, and Windows.
Proxies by platform
Proxies for Web Scraping: unmetered dedicated IPv4 & ISP pools for 24/7 crawlers
High-speed HTTP(S) dedicated IPv4 and Static ISP proxies for Python, Playwright, Selenium, and Scrapy with unlimited monthly bandwidth.
Proxies by platform
Proxies for Airdrops & DePIN (Grass): prevent Sybil flags with dedicated Static ISP IPs
Farm Web3 airdrops, testnets, and DePIN browser nodes (Grass, Dawn, Nodepay) safely. Dedicated Static ISP and private IPv4 proxies.
Proxies by platform
Proxies for SEO & SERP Tracking: accurate keyword rankings across 7 countries
Track localized keyword rankings, audit geo-redirects, and run Screaming Frog crawls with unmetered dedicated IPv4 and Static ISP proxies.
IPV4 · singapore
Singapore Private IPv4 Proxies: Fast, Dedicated SG IPs for Regional Selling and Ads
Dedicated Singapore private IPv4 proxies for Lazada and Shopee SG stores, regional ad accounts, ad verification and low-latency automation. Unlimited data.
IPV4 · united states
US Private IPv4 Proxies: Fast, Dedicated American Datacenter IPs
Dedicated US private IPv4 proxies for scraping, rank tracking, ad checks and Amazon research. Static IP, one user per IP, unlimited bandwidth, fast activation.
Use cases
Proxies for Web Scraping and Data Collection
Choose proxies for web scraping: fast private IPv4 for most sites, static ISP for stricter ones, unlimited bandwidth, and how to scrape responsibly.