Created
February 12, 2015 21:46
-
-
Save buth/9fcef2c106e3cc630c16 to your computer and use it in GitHub Desktop.
MongoDB authenticated Replica Set via environment variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=mongodb | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
RestartSec=5s | |
TimeoutStartSec=0 | |
KillMode=none | |
ExecStartPre=-/usr/bin/docker kill mongodb | |
ExecStartPre=-/usr/bin/docker rm mongodb | |
ExecStartPre=/usr/bin/mkdir -p /data/mongodb | |
ExecStartPre=/usr/bin/docker pull mongo:2.6 | |
ExecStart=/opt/bin/context exec -g mongodb docker run -e KEY --rm -m 1g --name=mongodb -v /data/mongodb:/data/db -v /etc/mongodb:/etc/mongodb:ro -p 27017:27017 mongo:2.6 sh -c 'touch /keyfile; chmod 600 /keyfile; chown mongodb:mongodb /keyfile; echo $KEY | fold -w 64 > /keyfile; exec mongod --replSet rs0 --keyFile /keyfile' | |
ExecStop=/usr/bin/docker stop mongodb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment