I have two containers one running python
and other one running mongodb
. Now I want to run mongoimport
command from my application container.
So how do I do it?
I have two containers one running python
and other one running mongodb
. Now I want to run mongoimport
command from my application container.
So how do I do it?
docker exec
should be reserved for debugging purposes.
Ideally, you would run mongoimport
at build time from your Dockerfile
, in order to make an image dedicated to seed your mongo database.
For instance, look at "How do I seed a mongo database using docker-compose?"
That way, you avoid any manual runtime operation.
If you must have a regular runtime operation, then you need to add to your image a cron
, as I described here.
That way, you can execute that mongoimport
on a regular basis, during the time the container is running.