如何启动CoreOS的云configuration文件的Docker容器?
我正在尝试使用Terraformconfiguration我的CoreOS服务器,使用CoreOS的云configuration文件 。 我目前正在尝试在Docker容器中设置Mongo数据库。 这是我的configuration文件:
write_files: - path: "/home/core/keyfile" permissions: "0600" owner: "999" content: | hUoQVrERB0*** <here is my key for MongoDB> coreos: units: - name: "dockerstart.service" command: "start" content: | [Unit] Description=Start Author=Me [Service] Restart=always ExecStart=/usr/bin/docker run --name mongo -v /home/core:/opt --add-host node1.example.com:127.0.0.1 -p 27017:27017 -d mongo:2.6.5 --smallfiles --keyFile /opt/keyfile --replSet "rs0" ExecStop=/usr/bin/docker rm -f mongo
我不知道如何使用coreOS units
(当我进入服务器,docker容器没有运行,所以configuration文件不正确)。 根据CoreOS Validator ,我的文件是有效的。 另外,我不确定这是否是部署MongoDB服务器的最简单的方法。 如何正确使用CoreOS units
? 任何想法,以改善如何部署一个Mongo数据库?
任何帮助,意见,build议表示赞赏!
我终于find了解决办法。
实际上,使用-d
选项docker run
docker docker run
守护命令。 所以,当systemd
发现这个动作在后台运行时,它认为Docker崩溃了。
这是在服务器上的journalctl -u dockerstart.service
结果:
docker[1237]: ace3978442a729420ecb87af224bd146ec6ac7912c5cc452570735f4a3be3a79 docker[1297]: mongo systemd[1]: dockerstart.service: Service hold-off time over, scheduling restart. systemd[1]: Stopped Start. systemd[1]: Started Start.
在这里,您可以清楚地看到systemd
停止并重新启动“ Start
服务。
所以这个解决scheme可能会从docker run
命令中删除-d 。