I have a nodejs app can take two parameters when started. For example, I can use
node server.js 0 dev
or
node server.js 1 prod
to switch between production mode and dev mode and determine if it should turn the cluster on. Now I want to create docker image with arguments to do the similar thing. The only thing I can do so far is to adjust the Dockerfile to have a line
CMD [ "node", "server.js", "0", "dev"]
and
docker build -t me/app .
docker run -p 9000:9000 -d me/app
to build and run the docker image.
But If I want to switch to prod mode, I need to change the Dockerfile CMD to be:
CMD [ "node", "server.js", "1", "prod"]
and I need to kill the old one listening on port 9000 and rebuild the image. I wish I can have something like
docker run -p 9000:9000 environment=dev cluster=0 -d me/app
to create an image and run the nodejs command with "environment" and "cluster" arguments, so I don't need to change the Dockerfile and rebuild the docker any more. How can I accomplish this?