mongo1: hostname: mongo1 container_name: localmongo1 image: mongo expose: - 27017 ports: - 27017:27017 restart: always entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ] volumes: - :/data/db # This is where your volume will persist. e.g. VOLUME-DIR = ./volumes/mongodb mongo2: hostname: mongo2 container_name: localmongo2 image: mongo expose: - 27017 ports: - 27018:27017 restart: always entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ] mongo3: hostname: mongo3 container_name: localmongo3 image: mongo expose: - 27017 ports: - 27019:27017 restart: always entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]