0

I am trying to run two commands in the docker cmd

following the instruction here this is my docker file

FROM mongo:5.0.14

CMD mongod;touch /tmp/testfile

Actually, I am trying to override the CMD in here

The reason I am trying to do this experiment is that I want to seed my mongodb without having another helper container as explained here

I want to run the mongoimport in the docker run stage

however, what I explained above is not working. what is the problem?

Amin Ba
  • 1,603
  • 1
  • 13
  • 38
  • A container runs a single process, then exits. I'd run a separate container to seed the data. The `mongo` image does [support a `/docker-entrypoint-initdb.d` directory](https://github.com/docker-library/docs/blob/master/mongo/README.md#initializing-a-fresh-instance) so you can put your initialization script there and not change the image's `CMD`. Also see [Initialize data on dockerized mongo](https://stackoverflow.com/questions/39348478/initialize-data-on-dockerized-mongo). – David Maze Feb 15 '23 at 20:14

0 Answers0