I have two Docker containers—redis
(running a Redis database) and node
(running a Node.js application). My Node.js application needs to communicate with the Redis database, but I'm not sure how I should arrange this. Here are some ways I've thought of so far:
- Put the two containers on one network, expose (but do not publish) port 6379 (or wherever the Redis server is listening) of the
redis
container, and connect to the exposed port from thenode
container. - Have the Redis server listen on a UNIX socket that is mounted to some location on the host (i.e., outside of the
redis
container) that is also mounted into thenode
container (willl that even work?). - Ditch the separate containers idea altogether and put the Redis server and Node app in the same container (I really do not want to do this).
Which option is the best, or is there something else that you would suggest? I want to maximize performance and security, but I also need to use container(s).
P.S. There are some similar questions to this one out there, but none of them seem to answer my question. That being said, if you find an existing answer that might help, please do link to it.