Address starting with 2, what mode I am in? I am using https://github.com/freewil/bitcoin-testnet-box to run bitcoind in docker to test signing of transactions.
make start tells me the bitcoind is started without -regtest flag. See https://github.com/freewil/bitcoin-testnet-box/blob/master/Makefile#L13
When I run bitcoin-cli -datadir=1 getblockchaininfo, I indeed see &quot;chain&quot;: &quot;regtest&quot; in output, so both the nodes are running in regression test mode, I believe.
If I generate an address for either of these 2 nodes, I get an address starting with 2:
tester@4df64413049e ~/bitcoin-testnet-box$ make address1
bitcoin-cli -datadir=1  getnewaddress
2N4DTeBWDF9yaF9TJVGcgcZDM7EQtsGwFjX
tester@4df64413049e ~/bitcoin-testnet-box$ make address2
bitcoin-cli -datadir=2  getnewaddress
2MwxP8fyh9MFqKnZXZuqt3ZYByhLpNVoiX3

make getinfo tells me its not testnet either:
tester@4df64413049e ~/bitcoin-testnet-box$ make getinfo
bitcoin-cli -datadir=1  -getinfo
{
  &quot;version&quot;: 170100,
  &quot;protocolversion&quot;: 70015,
  &quot;walletversion&quot;: 169900,
  &quot;balance&quot;: 0.00000000,
  &quot;blocks&quot;: 0,
  &quot;timeoffset&quot;: 0,
  &quot;connections&quot;: 1,
  &quot;proxy&quot;: &quot;&quot;,
  &quot;difficulty&quot;: 4.656542373906925e-10,
  &quot;testnet&quot;: false,
  &quot;keypoololdest&quot;: 1599940906,
  &quot;keypoolsize&quot;: 1000,
  &quot;paytxfee&quot;: 0.00000000,
  &quot;relayfee&quot;: 0.00001000,
  &quot;warnings&quot;: &quot;&quot;
}
bitcoin-cli -datadir=2  -getinfo
{
  &quot;version&quot;: 170100,
  &quot;protocolversion&quot;: 70015,
  &quot;walletversion&quot;: 169900,
  &quot;balance&quot;: 0.00000000,
  &quot;blocks&quot;: 0,
  &quot;timeoffset&quot;: 0,
  &quot;connections&quot;: 1,
  &quot;proxy&quot;: &quot;&quot;,
  &quot;difficulty&quot;: 4.656542373906925e-10,
  &quot;testnet&quot;: false,
  &quot;keypoololdest&quot;: 1599940906,
  &quot;keypoolsize&quot;: 1000,
  &quot;paytxfee&quot;: 0.00000000,
  &quot;relayfee&quot;: 0.00001000,
  &quot;warnings&quot;: &quot;&quot;
}

So what mode I am running these bitcoin nodes as? If I was to trust the output that its not testmode but somehow regression test mode, shouldn't the address start with 1 if its really regtest mode or with m/n if its testnet mode?
Also, when I dump the private key for any of such address and try to derive the P2PKH address from it, it doesn't match. Same code works fine with address and key taken from mainnet. What's going on?
Both regtest and testnet use the same address prefixes for the legacy and p2sh-segwit address types. Addresses beginning with 2 are p2sh, and if retrieved via getnewaddress, are guaranteed to be p2sh-segwit.
For bech32 type addresses, the regtest prefix is bcrt and on testnet it is tb. You can try fetching a bech32 address to see what the prefix is and be more sure of which network you are using.

shouldn't the address start with 1 if its really regtest mode

No, and that would be dangerous.
Both regtest and testnet intentionally use different prefixes than mainnet. You will never see mainnet prefixes in those modes.