I need to create a Dockerfile starting mongodb and initiating replicaset after that.
First I created a Dockefile as below:
FROM mongo:latest
EXPOSE 27017
ADD setup.sh /root/setup.sh
CMD ["bash","/root/setup.sh"]
Then I created the setup.sh file like this:
#!/bin/bash
mongod --fork --replSet rs0 --noprealloc --smallfiles
sleep 5
mongo --eval "rs.initiate()"
The problem is that it´s not working, am I doing something wrong?
Thanks!