If you're running into weird connection stalling issues when inside a Docker-in-Docker environment, it's rather likely MTU is the culprit. For example, when basic network connectivity works (ping works, curl example.com works) but curl to a https endpoint stalls at TLS handshake, this is likely due your container unable to receive packets larger than a certain value.

Normally, the networking stack is able to discover the MTU using ICMP, however some endpoints choose to block ICMP which causes this to not work.

The solution is to change your container's MTU option by putting this in your docker-compose.yml:

networks:
  default: # or whatever your networks are named
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1450 # You may need to lower this value further

The --mtu option passed to dockerd only affects the MTU used for pulls/pushes and does not affect containers themselves, which is rather annoying.