Skip to content

Instantly share code, notes, and snippets.

@renatomefi
Created September 20, 2018 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renatomefi/1d87c6a7c41f881748053d6d2c56edd5 to your computer and use it in GitHub Desktop.
Save renatomefi/1d87c6a7c41f881748053d6d2c56edd5 to your computer and use it in GitHub Desktop.
A mongo Dockerfile with SSL support out of the box
FROM mongo:4.0
# Works with Mongo 3.2 till 4.0
WORKDIR /etc/ssl
# If you want to validate the certifacate you should have it somewhere else an copy here, otherwise you won't be able to
RUN set -xe \
&& openssl req -newkey rsa:2048 -new -x509 -days 365 -nodes -out mongodb-cert.crt -keyout mongodb-cert.key -subj "/C=NL/ST=Noord Holland/L=Amsterdam/O=Me/OU=Somewhere/CN=mongo" \
&& cat mongodb-cert.key mongodb-cert.crt > mongodb.pem
ENTRYPOINT ["mongod", "--sslMode", "requireSSL", "--sslPEMKeyFile", "/etc/ssl/mongodb.pem"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment