Containers

What's the difference between these two forms:

ENTRYPOINT ["cmd", "param0", "param1"]
CMD ["param0"]

ENTRYPOINT cmd param0 param1
CMD param0

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

The first form is also referred as "Exec form" and the second one is referred as "Shell form".

The second one (Shell form) wraps the commands in /bin/sh -c hence creates a shell process for it.

While using either Exec form or Shell form might be fine, it's the mixing that can lead to unexpected results.

Consider:

ENTRYPOINT ["ls"]
CMD /tmp

That would results in running ls /bin/sh -c /tmp