I am using multiple Dockerfiles to setup my server infrastructure. One of the Dockerfiles I build is a MongoDB server which will be linked to a running web server application in a later step. Currently, I have the problem when running the MongoDB server I receive following error:
"Error parsing command line: unknown option port 27017"
In my Dockerfile I have:
CMD ["--port 27017", "--dbpath /data/db", "--smallfiles"]
ENTRYPOINT ["/usr/bin/mongod"]
When I use instead of the above commands the following everything works:
CMD /usr/bin/mongod --port 27017 --dbpath /data/db --smallfiles
I prefer the CMD - Array and ENTRYPOINT approach more but cannot figure out why I receive the error.
When using the json syntax, you need to pass each argument individually. It will consider each element as one whereas in the non-json syntax, it will be split by the shell and considered as two.
CMD ["--port", "27017", "--dbpath", "/data/db", "--smallfiles"]
will work.
Alternatively, I don't know if mongo supports it, but most softwares does, you could do this:
CMD ["--port=27017", "--dbpath=/data/db", "--smallfiles"]
so it will get passed as one element but will be interpreted by mongo.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.