Next, let's improve our Dockerfile by applying best practices.
Following best practices
Shell versus exec forms
The RUN, CMD, and ENTRYPOINT Dockerfile instructions are all used to run commands. However, there are two ways to specify the command to run:
- shell form;Â RUN yarn run build: The command is run inside a new shell process, which, by default, is /bin/sh -c on Linux and cmd /S /C on Windows
- exec form;Â RUN ["yarn", "run", "build"]: The command is not run inside a new shell process
The shell form exists to allow you to use shell processing features like variable substitution and to chain multiple commands together. However, not every command requires these features. In...