I want to create a Docker container with an instance of Mongo. In particular, I would like to create a replica set with only one node (since I’m interested in transactions and they are only available for replica sets).
FROM mongo RUN echo "rs.initiate();" > /docker-entrypoint-initdb.d/replica-init.js CMD ["--replSet", "rs0"]
version: "3" services: db: build: dockerfile: Dockerfile context: . ports: - "27017:27017"
If I use the Dockerfile alone everything is fine, while if I use docker-compose it does not work: in fact if I then log to the container I got prompted as
rs0:OTHER> instead of
I consulted these links but the solutions proposed are not working: