How to Secure Your Docker Environment with NordVPN

How to Secure Your Docker Environment with NordVPN

Docker is a powerful tool that allows you to easily deploy and manage applications in a containerized environment. If you’re also a user of NordVPN, you may wish to pass the traffic coming from your Docker containers through Nord to secure your internet connection and protect your online privacy. By the end of this tutorial, you will know how to set up NordVPN on a Docker container and use it to protect the internet connection off other Docker containers as well. Let’s get started!

How To Run The NordVPN Client within a Docker Container

So we need a container that can run the NordVPN client, which other containers can then communicate through using the --net option in Docker. We can either build our own container or use a prebuilt one. If you wanted to go the route of building your own container, NordVPN has some instructions on their website on building their CLI into a Docker container. You can find those here.

For the purpose of this tutorial, I’ll be going over how to use a prebuilt container. In particular, the container from This project is actually a fork of an OpenVPN client that has been modified slightly to work with NordVPN with less end user configuration, since NordVPN is actually OpenVPN compatible.

Running this container is pretty straightforward. All we need to replace below are the credentials we use to log into NordVPN.

docker pull bubuntux/nordvpn

docker run -ti --cap-add=NET_ADMIN --cap-add=SYS_MODULE --device /dev/net/tun --name vpn --sysctl net.ipv4.conf.all.rp_filter=2 -e USER=**** -e PASS=**** -e CONNECT=United_States -e TECHNOLOGY=NordLynx -d bubuntux/nordvpn

Passing Network Traffic From Other Containers Through NordVPN

Now that we have our NordVPN container connected and running, we can start other containers that will then connect to the internet through the NordVPN container. This is just a simple option we can pass into additional docker run commands. Since we named our NordVPN client container vpn above, the option we have to pass in is --net=container:vpn. In a full docker run command this would look like the below.

docker run -it --net=container:vpn ubuntu

That’s all there is to it. Any internet traffic from the above Ubuntu container will pass through the NordVPN container and subsequently the NordVPN network, leaving your internet traffic secure and encrypted.

Leave a Reply