0

I have below Docker cmd:

docker run -it -p 27017:27017 -v /Users/john/db/:/data/db --name k1 mongo

When I run above command, I want to precheck whether "/Users/john/db/" folder path already exists or not. If it does not exist, then I want to throw a custom exit code and stop the container from starting.

How to do this?

If I write an entrypoint script which will run before container starts, how would I access -v arguments? means this "/Users/john/db/" in entrypoint bash/python script?

deadMan
  • 35
  • 1
  • 7
  • I do not know about the custom exit code, but I believe if you use `--mount type=bind,source=/Users/john/db,target=/data/db,readonly=false` then it will not start the container if `/Users/john/db` does not exist. – emory Feb 07 '19 at 06:00
  • 1
    In general, your entrypoint script can not access the `-v` arguments. It is possible, but should be considered a kludge. Do not do it. – emory Feb 07 '19 at 06:03

0 Answers0