This project connects a DNS server and a VPN so that you can connect to containers in a docker network from your macOS host and resolve their names using DNS.
Install docker desktop
brew install openvpn
Make sure to export paths for `openvpn` bin in your ~/.zshrc
export PATH=/usr/local/opt/openvpn/sbin:$PATH
git clone https://github.com/jsab/devdns.git
cd devdns
docker build -t devdns-patched .
- Run
./macos_config.sh
once to configure your mac.
- If you have run this before,
rm client-config/*.ovpn
to clean up any past configurations. - Set
DOCKER_NETWORK
to the docker network you want to connect to. For example:export DOCKER_NETWORK=curbside-ad_default
- Run
docker-compose up -d
to spawn both the VPN and the DNS servers. - Run
./connectvpn.sh
to connect your mac host to the VPN.
The last step should print a message confirming the initialization completed successfully:
Initialization Sequence Completed
- In case of multiple test failures, check if redis docker is accessible by
ping curbside-ad-redis
- If ping fails with following error:
ping: cannot resolve curbside-ad-redis: Unknown host
- Then clear dns cache with
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
(verified on macOS Big Sur)
- Then clear dns cache with
- Else, check for
docker-compose logs dns
in curbside-docker-network- If dns logs have content like
Could not get IP for container curbside-ad-redis, probably not on network curbside-ad_default, skipping...
- Then issue is AD folder name mismatch. Rename it to
curbside-ad
. - Restart docker with
docker-compose down
anddocker-compose up -d
- Then issue is AD folder name mismatch. Rename it to
- Else collect ip address from logs. It should be like
Added curbside-ad-redis.docker → 172.20.0.4
- Try
ping <curbside-ad-repl-ip-address>
. If ping to ip is successful andping curbside-ad-redis
still fails, then flush dns
- Try
- If dns logs have content like
- If still not solved, try system reboot
- If ping fails with following error:
- In case you have `ERROR: for curbside-vpn Cannot start service vpn: network <NetworkID> not found` that means the
NetworkID
of the network you are trying to connect changed (most likely because you diddocker-compose down
) and the current container still refers to the oldNetworkID
. You will have todocker-compose down
curbside-docker-network
too. and you need to down the network container as well. The network ID changes every time a container is downed and upped.