Shell form vs Exec FORM
- When we use Shell form , internally it runs with
/bin/sh -c <command>
RUN apt update => /bin/sh -c apt update
RUN python test.py => /bin/sh -c "python test.py"
- When we use exec form it directly starts your executable
CMD ["python", "test.py"] -> python test.py
- If we want dynamic values from arguments or variables then only option is shell form
CMD ["wget", "$URL"] => This will not work
RUN wget ${URL} => This will work
- EXEC FORM respects linux signals which allows docker engine to send signals during stop and restart or even terminate
- CMD and ENTRYPOINT come into play when container is starting and thats where signals are essential