It appears that Fred Tingey's answer was mostly correct, but contained incorrect port numbers in the samples he provided. If someone were to copy and paste it all it would not have worked correctly.
I've modified his answer, it is awaiting peer review.
The use of Ubuntu, Docker and VirtualBox shouldn't affect your ability to configure regtest.
You may have problems connecting from the host to the guest, if you do I suggest perhaps asking questions on superuser or ubuntu exchanges instead.
Hope that helps!
=== Here's the edited version:
In order to run multiple nodes in regtest mode on a single machine you will need to sandbox each node.
In this example I have three nodes, they are named Alice, Bob and Cory. Since Bitcoin is a Peer/Mesh network, my goal is to connect each nodes so that changes made to Cory are ultimately visible to Bob (without necessarily requiring a direct connection between the two.)
Step 1: Create folders for each node.
These folders will contain our data and configs for each node. The names are not important, they can be renamed later, so you can name them "Alice", "Bob" and "Cory" for now. Remember where you create them, you will need their paths for Step 3 below.
Step 2: In each folder, create a bitcoin.conf file
In the config files Alice will be configured to connect to Cory, and Bob will be configured to connect to Alice. In addition to configuring outbound connections, this is also where we specify
bitcoin.conf for Alice
# Alice connects to Cory
bitcoin.con for Bob
# Bob connects to Alice
bitcoin.conf for Cory
# Cory connects to nobody
Step 3: Start each node.
Note each node must have a different port number since only one node can bind to a port number at any time.
- Alice on port 18444
- Bob on port 18555
- Cory on port 18333
You can choose your own port numbers of course, just be careful not to use a port number that is already in use by something else.
The command-line options will tell bitcoin what port number to use, where to store data, and where to find its config file:
"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Cory\bitcoin.conf" -datadir="C:\Cory" -port=18333 -rpcport=8333
"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Bob\bitcoin.conf" -datadir="C:\Bob" -port=18555 -rpcport=8555
"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Alice\bitcoin.conf" -datadir="C:\Alice" -port=18444 -rpcport=8444
This will launch three instances of the Bitcoin Client, and the folders for each node will begin to initialize with regtest data.
Step 4: Testing
You can use the
Help->Debug Window->Console option to interactively execute commands on any of the nodes. For example, you can mine 101 blocks with the following bitcoin console command:
setgenerate true 101
You should (after a few seconds) then have been awarded coins.
These mining activities result in coinbase transactions - and only the last one of 50 BTC is available to spend. Now you can send some BTC to one of the other nodes. After a bit more mining such a transaction will be confirmed.
You can also use the console commands
getinfo to check the network is set up correctly. One of them (Core wit port=18333) should have 'sync=true' in its peerinfo output, and all nodes should have the same "block height" regardless of which node is used for mining.