Skip to content

Docker Newbie question: How to run shell script in docker file (post startup) #191

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
ikemtz opened this issue Jul 25, 2017 · 2 comments
Closed

Comments

@ikemtz
Copy link

ikemtz commented Jul 25, 2017

I'm trying to run a mongorestore command as part of my docker file. I'm thinking that this should be a pretty straight forward thing to do.

Here's my docker file:
FROM mongo:latest
RUN mongodump -h xxxxxx -u xxxxx -p xxxxxx --ssl --sslAllowInvalidCertificates -d xxxxx --gzip --archive=DbArchive.archive
EXPOSE 27018:27017
ENV AUTH no
ENV JOURNALING no
RUN mkdir -p /usr/src/db
COPY ./*.sh /usr/src/db/
RUN chmod +x /usr/src/db/restoreDb.sh
#CMD /bin/sh ./usr/src/db/restoreDb.sh

Here's my restoreDb.sh script
sleep 60
mongorestore --archive=DbArchive.archive --gzip --db xxxxxxx

Anyone have any ideas on how to get this to work? I'm just trying to run my mongorestore after the mongo db has started.

When I execute the following scripts I get the following error message:
2017-07-25T00:05:48.352+0000 Failed: error connecting to db server: no reachable servers

@ikemtz ikemtz changed the title Docker Newbie question: How to run shell script in docker file Docker Newbie question: How to run shell script in docker file (post startup) Jul 25, 2017
@yosifkit
Copy link
Member

Have you tried /docker-entrypoint-initdb.d/? It was added in #145. I still consider it experimental (which is why it is not documented), but it should work similar to mysql and postgres.

@tianon
Copy link
Member

tianon commented Dec 20, 2017

Closing, since /docker-entrypoint-initdb.d is the appropriate solution to this problem. 👍

@tianon tianon closed this as completed Dec 20, 2017
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