0

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.

Robert Weindl
  • 1,092
  • 1
  • 10
  • 30
  • As a docker fan I still have to say that there is [serverfault.com](http://serverfault.com/) that is really where your question needs to be posted. StackOverflow is not the "dump bucket" for "all things computing" that it once was. There are now dedicated sites to ask these questions. StackOverflow is for "programming topics" only. – Neil Lunn Jun 24 '14 at 15:41

1 Answers1

3

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.

creack
  • 116,210
  • 12
  • 97
  • 73