To use docker run command to pass arguments to CMD in Dockerfile, we run CMD
with an array.
For instance, we write
CMD ["sh", "-c", "node server.js ${cluster} ${environment}"]
in our Dockerfile to run the sh command with the arguments after it.
cluster
and environment
are the environment variables we defined in the docket-compose.yml file like
node:
environment:
- environment=dev
- cluster=0