I have installed a lower version of 7.0.16 and enabled the replica set; it worked for me. I am not sure why the replica set is not worked for 8.0.6 version in VM machine