Really simple Dockerfile:
#create DB directory
RUN mkdir -p /data/db
When I run the container I want to automatically create a DB called “CBDB”. I do not want to manually run the mongo shell, want the new DB to be created automatically.
code a shell to call the mongo shell ,than use the CMD to call the shell
Could write a
docker-entrypoint.sh that creates the db. You will still be able to specify CMD at run time. While, probably not matter for mongodb.
COPY docker-entrypoint.sh /usr/local/bin/