Skip to content

docker-entrypoint-initdb.d not working #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SimonTulettIdeaco opened this issue Aug 28, 2017 · 6 comments
Closed

docker-entrypoint-initdb.d not working #200

SimonTulettIdeaco opened this issue Aug 28, 2017 · 6 comments

Comments

@SimonTulettIdeaco
Copy link

SimonTulettIdeaco commented Aug 28, 2017

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?

@yosifkit
Copy link
Member

Did you start it once and then change scripts and environment variables? It is probably the same as docker-library/postgres#203 (comment).

@SimonTulettIdeaco
Copy link
Author

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

@yosifkit
Copy link
Member

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.

@jtcmedia
Copy link

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.

@yosifkit
Copy link
Member

@jtcmedia, use a newer version of the mongo image. The initdb functionality was added in #145, which was on MongoDB version 3.2.12.

@jtcmedia
Copy link

Ah, thank you. I am using 3.2.9 because that's the default for dokku.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants