简体   繁体   English

在AWS EC2中运行自定义的mongo容器

[英]Running customized mongo container in AWS EC2

I'm trying to running a cluster containing two containers, one with an image that runs a node.js server, and one container for a mongo db. 我正在尝试运行一个包含两个容器的群集,一个包含运行node.js服务器的映像,一个包含mongo db的容器。

I'm following this tutorial , which states to use registry.hub.docker.com/library/mongo:latest as the image url for the mongodb. 我正在按照本教程进行操作该教程指出使用registry.hub.docker.com/library/mongo:latest作为mongodb的图像URL。

Now, I have a problem. 现在,我有一个问题。 Locally, when I run the mongo container on my pc, I use the following script , which does two things: 在本地,当我在PC上运行mongo容器时,我使用以下脚本 ,该脚本有两件事:

  1. Executes docker run with a mongo image, stating --replSet in the arguments 使用mongo映像执行--replSet docker run ,并在参数中声明--replSet
  2. Runs two shell commands - initating the replica set, and setting up an initial user. 运行两个Shell命令-初始化副本集和设置初始用户。

The hard part I can't wrap my head around, is the --replSet part. 我无法缠住的--replSet部分是--replSet部分。
When I run the container the the official mongodb image, it initiates mongod in some default way. 当我运行容器的官方mongodb映像时,它将以某种默认方式启动mongod

Say, I create a new Dockerfile , which states FROM mongo:latest . 说,我创建了一个新的Dockerfile ,其状态为FROM mongo:latest
To my limited understanding, the rest of the things that will happen in the custom Dockerfile , the mongod is already ran. 据我有限的了解,其余的将在自定义Dockerfile发生, mongod已经运行。 Is there any way I can modify that way it is executes in mongo:latest , or modify an already active mongod to allow the --replSet option? 有什么办法可以修改它在mongo:latest执行的方式,还是修改一个已经处于活动状态的mongod以允许--replSet选项?

The shell commands on the mongo shell, as far as I understand, won't be a problem, since this is just a couple of RUN commands in the Dockerfile . 据我了解,mongo shell上的shell命令不会有问题,因为这只是Dockerfile的几个RUN命令。

Thanks in advance for helping! 在此先感谢您的帮助!

我设法仅在ECS任务的网络模式设置为bridged下运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM