Skip to content

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

License

Notifications You must be signed in to change notification settings

rakutenrewards/curbside-docker-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Prerequisites

docker-compose

Install docker desktop

openvpn

brew install openvpn

Make sure to export paths for `openvpn` bin in your ~/.zshrc

export PATH=/usr/local/opt/openvpn/sbin:$PATH

Patched devdns

  1. git clone https://github.com/jsab/devdns.git
  2. cd devdns
  3. docker build -t devdns-patched .

Installation

  1. Run ./macos_config.sh once to configure your mac.

Usage

  1. If you have run this before, rm client-config/*.ovpn to clean up any past configurations.
  2. Set DOCKER_NETWORK to the docker network you want to connect to. For example:
    export DOCKER_NETWORK=curbside-ad_default
        
  3. Run docker-compose up -d to spawn both the VPN and the DNS servers.
  4. 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

Troubleshoot curbside-ad test failures:

  • 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)
    • 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 and docker-compose up -d
      • 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 and ping curbside-ad-redis still fails, then flush dns
    • If still not solved, try system reboot
  • 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 did docker-compose down) and the current container still refers to the old NetworkID. You will have to docker-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.

About

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

Resources

License

Stars

Watchers

Forks

Languages