92

I have a really long command line for the default process due to a number of arguments. I think the easiest would be to create a script (for eg.run.sh) and then call this script in your ENTRYPOINT or CMD. I'm wondering if there is a way to make your ENTRYPOINT or CMD multiline (the way we write RUN). For eg.

ENTRYPOINT["/path/myprocess",
           "arg1",
           "arg2" ]

I was thinking this is a valid syntax since the format is json. However, docker build throws the error

Step 14 : ENTRYPOINT[
Unknown instruction: ENTRYPOINT[

Is there a way I can split the ENTRYPOINT to multiple lines?

donnie
  • 2,981
  • 2
  • 16
  • 24
  • 2
    My mistake. I missed a space between `ENTRYPOINT` and `[` . I found that dockerfile supports multiline `ENTRYPOINT` and `CMD` by terminating the line with `\`; same as `RUN`. – donnie May 11 '16 at 09:47
  • Add the answer and accept it then :) – L0j1k May 11 '16 at 14:41

1 Answers1

144

It was a typo in the dockerfile. I missed a space between ENTRYPOINT and [. Dockerfile supports multiline ENTRYPOINT and CMD by terminating the line with \, same as RUN. So, in my case it can be

ENTRYPOINT [ "/path/myprocess", \
             "arg1",            \
             "arg2"             \
]
donnie
  • 2,981
  • 2
  • 16
  • 24
  • 6
    when I tried that with multiline CMD parts as CMD ["/bin/sh", "-c", \ "java", \ "-jar ..." \ ] , my linux docker 18.09.1 image run executed java without arguments. Had to switch to CMD ["/bin/sh", "-c", \ "java, \ -jar ..." \ ] (removed quotes between multilined java args) – glebsts Feb 21 '19 at 09:55