Search code examples
phpdockervpnlaradock

Docker VPN tunnel to remote database


I am using Laradock to run a development version of a website.

It needs to access a database on Amazon through a VPN tunnel.

I have set up the VPN tunnel on my PC using Putty, so I have a local port 1234 forwarding to the remote DB port.

2021-07-05 07:33:12 Local port 1234 forwarding to mydb.eu-west-1.rds.amazonaws.com:1234

How do I configure Laradock and/or Docker to use the tunnel on my local machine?

Alternatively how can I set up a tunnel that the Docker container can use?

Edit: Solved - see answer below


Solution

  • Docker containers use host.docker.internal as the hostname for your local system, so using it as the hostname for the database allows connection to the VPN tunnel.