Automatic bootstrap MongoDB cluster within Docker Swarm?

Is it possible to bootstrap a MongoDB cluster automatically within Docker Swarm? The idea is to launch 3+ instances, supply them with the same keyfile and setup the service name not as VIP (Virtual IP) in Docker DNS but let Docker return all A records when the service name is resolved through Docker DNS.

Does MongoDB have the functionality to bootstrap a cluster with those supplied IPs?

Or is it only possible to create the cluster manually (doc)?

docker exec -it mongo1 mongosh --eval "rs.initiate({
 _id: \"myReplicaSet\",
 members: [
   {_id: 0, host: \"mongo1\"},
   {_id: 1, host: \"mongo2\"},
   {_id: 2, host: \"mongo3\"}
 ]
})"

Plan B: Is it possible to use IPs instead of mongo1,mongo2,mongo3? What happens if this is executed on every node? When they are already in a ReplicaSet?