Afterwards, you can override the runtime command line to specify npm start or npm debug.
If you use docker-compose, you can specify a .env file, a default variable:
Then in your docker-compose.yml
Then on the command line you can do MODE=debug docker-compose up -d
Make sure that you point the default server from localhost to whatever the output of docker-machine ip, if you are on OS X. If on Linux, then localhost is fine.
Another idea I thought about was to specify a DEBUG_OPTS environment variable, which is an empty string, but if NODE_DEBUG=1, then I set DEBUG_OPTS to be equal to "--debug=5858". The only way to get programatic functionality in Docker is to use a wrapper script, and bootstrap the wrapper script instead of calling node directly. Most shops that have to do complex things, seed/migrate an external database or other application orchestration, then wrapper scripts are used. Otherwise, for simple applications, package.json method is easier.
- Joaquin