Thursday, 5 December 2019

docker, just start the image without run anything

i have a mongo shell script i need to call it by corntab.

to run it, i need mongo shell client, which is included in mongo.

good news is that mongo docker has it.

i just want to start a mongo docker image, but i don't want to start the db.

my Dockerfile is

FROM mongo:latest
CMD tail -f /dev/null

if i just do FROM mongo:latest, then it will auto start the db. because it will inherit CMD which do mongod.

i need to override it, but the new CMD must keep running to hold the server, otherwise it will just start and run the command and stop the image after the command returns,.

tail -f will keep it running.

No comments:

Post a comment