I am developing a web application that communicates with MongoDB, so I am using docker to develop/test locally.
My docker compose is like this:
services:
auth-terrai:
image: auth-app
build:
context: ..
dockerfile: docker/Dockerfile
command: air -c .air.toml
volumes:
- ../:/app
- ../:/go/src/gitlab.com/main/server
ports:
- 8080:80
- 10000:2345
environment:
- VERSION=0.0.1
- TITLE= App
- DESCRIPTION=
- ENVIRONMENT=dev
- HOST=localhost:8080
- WHITE_LIST=./key/white_list.json
- FIREBASE_SERVICE_ACCOUNT=./key/service_account.json
- MONGO_URL=mongodb://abc123:abc123@urt-mongo-db:27017
- MONGODB_NAME=auth
networks:
- urt-guane
urt-mongo-db:
image: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: abc123
MONGO_INITDB_ROOT_PASSWORD: abc123
MONGO_INITDB_DATABASE: auth
ports:
- 27017:27017
volumes:
- urt-mongo-db:/data/db
networks:
- urt-guane
volumes:
urt-mongo-db:
external: true
networks:
urt-guane:
external: true
In a flow of my application, I need to use transactions, but I get this error:
Transaction numbers are only allowed on a replica set member or mongos
As I understand it, I must have a set of replicas to be able to use transactions. I really only want 1 replica, I just need to be able to test my flow. I was following several examples but it hasn’t worked for me. How should I modify my docker compose to be able to use transactions?