How to Route Any Docker Container Through NordVPN (macOS Friendly)

This guide shows you how to run NordVPN in Docker and force other containers to use it for all their internet traffic.

This is the correct method for macOS using Docker Desktop. If you need the Windows version of this, click here.


What You’re Doing (in plain English)

You will:

  1. Run one container that connects to NordVPN
  2. Run other containers that “piggyback” on that VPN container
  3. Those containers will now appear on the internet as NordVPN IPs

Click to download the ZIP of the Docker files

Click For Special NordVPN Deal

PRE-STEP – Get NordVPN Service Credentials

If you’re running NordVPN in Docker (or using OpenVPN/WireGuard manually), you do NOT use your email + password.

You must use Nord’s Service Credentials.

These are separate, special credentials designed specifically for:

  • OpenVPN
  • WireGuard / NordLynx
  • Routers
  • Docker containers
  • Manual setups

Step 1 – Log Into Your Nord Account

Go to:

https://my.nordaccount.com

Log in with your normal Nord email + password.


Step 2 – Go to “Set Up NordVPN Manually”

Once logged in:

  1. Click NordVPN
  2. Click Set up NordVPN manually

You are now on the page that shows Service credentials.


Step 3 – Copy Your Service Username & Password

You will see two fields:

  • Username (looks like random letters/numbers, not your email)
  • Password (random string)

These are your service credentials.

👉 Copy both of them.
👉 These are what Docker / OpenVPN will use.

Do NOT use:

  • your email
  • your Nord website password

They will not work.


Step 4 – Paste Them Into Your .env File

Open the .env file in the starter pack and paste:

OPENVPN_USER=PASTE_SERVICE_USERNAME_HERE
OPENVPN_PASSWORD=PASTE_SERVICE_PASSWORD_HERE

Example:

OPENVPN_USER=ab123456
OPENVPN_PASSWORD=9xY#Lk2Pq!

Save the file.

🛑 DON’T MISS THIS DEAL
Your government, Internet Service Provider, app/addon/IPTV developers, and all websites document and record your online activity through your identifying IP address.
Your Current Identifying IP Address (digital fingerprint): 18.97.14.83
Browse anonymously by using NordVPN
TODAY’S DEAL
SAVE 72% ON NORDVPN + 3 FREE MONTHS
NordVPN backs their service with a 30-day money-back guarantee
Use your account on 10 devices with blazing fast speeds & thousands of servers
CLAIM NORDVPN DISCOUNT

Step 1 – Set Up the VPN Container

Download the .zip here.

This container:

  • connects to NordVPN
  • creates the encrypted tunnel
  • becomes the “internet gateway” for other containers

Step 2 – Add Your App Container

Any container you want to route through the VPN gets this line:

network_mode: "container:gluetun"

That is the entire magic.

Example:

services:
gluetun:
image: qmcgaw/gluetun
myapp:
image: your-image
network_mode: “container:gluetun”

Now:

  • myapp does not use your real IP

  • it uses the NordVPN connection from gluetun

Step 3 – Start Everything

From the folder with docker-compose.yml:

docker compose up -d

That’s it.

No extra networking.
No firewall rules.
No proxies.
No hacks.


Step 4 – Verify It’s Working

To confirm traffic is going through NordVPN:

docker exec -it gluetun curl https://ipinfo.io/ip

If the IP is:

  • not your home IP

  • shows a different country

Then it’s working.

Every container using network_mode: container:gluetun will have the same VPN IP.

Click For Special NordVPN Deal


Important Rules (Read This Once)

1. You do NOT expose ports on the app container

This is wrong:

myapp:
ports:
- "3000:3000"

It will not work.


2. You expose ports on the VPN container

This is correct:

gluetun:
ports:
- "3000:3000"

Because:

  • the app shares the VPN container’s network

  • all traffic goes through gluetun


3. They share localhost

Inside the VPN container:

curl http://127.0.0.1:3000

…will hit your app.

Because they are literally sharing the same network stack.


Example: Real-World Pattern

Node API behind VPN

services:
gluetun:
image: qmcgaw/gluetun
ports:
- "3000:3000"
api:
image: your-api-image
network_mode: “container:gluetun”

Scraper behind VPN (no ports)

services:
gluetun:
image: qmcgaw/gluetun
scraper:
image: your-scraper-image
network_mode: “container:gluetun”

Mental Model (This Makes It Click)

Think of it like this:

[ Your App Container ]
|
| (no internet)
v
[ VPN Container ] ---> NordVPN ---> Internet

Your app:

  • cannot touch the internet directly

  • is forced to go through the VPN container

That is why this method is clean, safe, and leak-proof.

Click For Special NordVPN Deal