0

I've seen docker commands expressed in Dockerfile written within brackets or without them. But when to use one case or the other?

#within brackets
RUN ["apt-get", "update"]

#without brackets
RUN apt-get update
Sos
  • 1,783
  • 2
  • 20
  • 46
  • 2
    Hey, seems like your question is answered in this post: https://stackoverflow.com/questions/62206384/cmd-and-entrypoint-bracket-vs-non-bracket-version – Punker Jul 13 '21 at 11:43
  • 1
    The only hard-and-fast rule is that `ENTRYPOINT` must use the JSON-array form if you don't want it to ignore the `CMD`. If you're spelling out `sh -c '...'` use the shell form instead (without brackets or an explicit `sh` command, Docker provides that for you). `RUN` is almost always shell form, but also very often uses shell-syntax `command1 && command2`. – David Maze Jul 13 '21 at 11:50

0 Answers0