I have a Node.js application running Express in one Docker container, while Redis is running in another. I'm looking to set up SSL between them using a self-signed certificate for testing purposes. I've come across a few methods:
1. **Generating the certificate inside the Redis container using a custom Dockerfile:**
- *Pros:* The OpenSSL version can be pinned and no additional containers are needed.
- *Cons:* OpenSSL needs to be installed with Redis, and client certificates are required on the local machine for connecting to Redis.
2. **Running certificate generation in a separate container:**
- *Pros:* Keeps the main Redis container clean, allowing you to pin the OpenSSL version.
- *Cons:* An extra container will run and stop, and you still need client certificates on the local machine.
3. **Generating certificates locally without additional containers:**
- *Pros:* No need for extra containers.
- *Cons:* You must share the certificate files with the Redis container, and the OpenSSL version is dependent on the local environment.
Considering these options, I'm looking for insights on the best approach or any alternatives you might suggest.
2 Answers
I’d recommend generating the local certificate and passing it through to the Redis container using volumes. I’ve been doing this in my pre-production environments without issues related to different OpenSSL versions. I generate root certificates with tools like mkcert, then distribute them across my LAN servers. For local development, try to keep it simple and avoid mandatory dependencies like Redis unless necessary. The fewer moving parts, the easier it is to manage during development!
It’s a good point that managing multiple containers for cert generation could complicate things. If each service (like Redis and Postgres) needs its own container for certs, it can get resource-heavy. Generating certificates directly on your local machine and storing them in a dedicated directory sounds much cleaner. Just make sure to add that directory to your .gitignore! Having scripts to handle the certificate generation can also streamline the process.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically