Transactions failing on a replica set

Hello Mongo community,

I started recently to learn MongoDB and decided to deploy my first replica set with Docker and practice transactions. So, I’ve create my compose file and deployed a replica set with one primary and two secondary nodes. Below I am attaching the docker-compose.

version: "3.8"
services:
  mongo1:
    image: mongo:latest
    container_name: mongo1
    command: mongod --replSet rs0 --bind_ip localhost,mongo1
    ports:
      - "27017:27017"
    networks:
      - mongoCluster

  mongo2:
    image: mongo:latest
    container_name: mongo2
    command: mongod --replSet rs0 --bind_ip localhost,mongo2
    ports:
      - "27018:27017"
    networks:
      - mongoCluster

  mongo3:
    image: mongo:latest
    container_name: mongo3
    command: mongod --replSet rs0 --bind_ip localhost,mongo3
    ports:
      - "27019:27017"
    networks:
      - mongoCluster

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

So far everything looks pretty good to me, until I get at the point where i am executing transactions in parallel. I’ve created two users with readWrite access to the database and I am opening sessions to the primary node with mogosh. I am trying to simulate executing transactions with each user in paraller, I am creating a session, start stransaction and executing the insert operation with the first user without any issues. When I create a session and start transaction with the second users, the user-1 transactions aborts, however I am still able to commit the user-2 transaction succesfully. I suppose I am doing something wrong with read/write concern settings, but I am not abe to figure it out. I’ve tried to read a bit more about the transaction and read/write concers, but to be honest I am nowhere at this point. I am attaching the steps I am executing with both users, if someone is able to give me a hint what I am doing wrong it will be great.

With user-1 connected to primary node

var session = db.getMongo().startSession( { readPreference: { mode: "primary" } } )
session.startTransaction({ 
  "readConcern": { "level": "local" }, 
  "writeConcern": { "w": "majority" } })
var customers = session.getDatabase("demo").getCollection("customers")
customers.insertOne({data})

With user-2 connected to primary node

var session = db.getMongo().startSession( { readPreference: { mode: "primary" } } )
session.startTransaction({ 
  "readConcern": { "level": "local" }, 
  "writeConcern": { "w": "majority" } })
var customers = session.getDatabase("demo").getCollection("customers")
customers.insertOne({data})
// This is where the transaction of user-1 aborts. On session.commitTransaction() everything seems to be working for user-2 and succesfully commits the record