bitcoin core – Automatic outbound connection using regtest nodes
Why is 18445 port used to bind when 2222 was mentioned in -bind while running bitcoind (node 1)?
When torcontrol is enabled, Bitcoin Core will listen on two separate ports by default: one for incoming connections from the public network, and one for incoming connections from tor. Using two separate ports helps Bitcoin Core distinguish which connections are tor connections and which ones aren’t.
You can override the port for incoming Tor connections too:
-bind=127.0.0.1:2223=onion would listen on port 2223 for those (and tell tor to forward incoming tor connections there).
How can I run a node 3 which discovers one of these nodes and creates an outbound connection automatically (node 2)?
Automatic connections are only for connecting to publicly reachable nodes. Unless you expose your 127.0.0.1:2222 port somehow to the Internet, the automatic connection mechanism doesn’t apply here. Even if it is, that’s probably not what you want.