I'm using mongo:3.2
This is my docker compose file
mongodb:
image: mongo:3.2
container_name: "mongodb"
volumes:
- ${MONGO_BACKUPS}:/backups
- ./databaseInit/mongoDB:/docker-entrypoint-initdb.d
ports:
- 27019:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: Password1?
This is my bash script contained in my local ./databaseInit/mongoDB folder
#!/usr/bin/env bash
mongorestore --gzip --archive=./backups/prod_backup_20170704 --db amp_blue_syd
When I run docker-compose build and or docker-compose up, there is no mention of the entrypoint.sh script attempting to execute my script. Can you let me know what I'm doing wrong?
Did you start it once and then change scripts and environment variables? It is probably the same as https://github.com/docker-library/postgres/issues/203#issuecomment-255200501.
Yep that was it thank you. Maybe an environment variable could be added which allows this to be forced if required without rebuilding the container? As per this Oracle container.
https://hub.docker.com/r/sath89/oracle-12c/
IMPORT_FROM_VOLUME=true
The root of this issue was solved. If you would like to discuss a way to force import scripts, I think that should be a new issue.
I think this issue should be re-opened. I can't get anything to execute in /docker-entrypoint-initdb.d. I've deleted volumes, deleted and re-created containers and images, deleted mong-seed on the host and nothing. My compose is dead simple:
db:
image: mongo:3.2.9
container_name: mongo
environment:
- MONGO_INITDB_DATABASE=my-db
volumes:
- ./mongo-seed:/docker-entrypoint-initdb.d
In the mongo-seed directory, I have seed-data.js which just contains:
db.flights.save({ ... })
I've used the same procedure with the MySQL image without issue.
@jtcmedia, use a newer version of the mongo image. The initdb functionality was added in https://github.com/docker-library/mongo/pull/145, which was on MongoDB version 3.2.12.
Ah, thank you. I am using 3.2.9 because that's the default for dokku.
Most helpful comment
@jtcmedia, use a newer version of the mongo image. The initdb functionality was added in https://github.com/docker-library/mongo/pull/145, which was on MongoDB version
3.2.12.