Docker with command line options - Mongo with replica set

docker

#1

Hello,

we want to use circleci’s prebuilt docker circleci/mongo:<TAG> with command line option --replSet rs0 to enable docker replica sets so that we can start enjoying change streams. If I were to run the docker from command line I would simply input:

docker pull mongo:3.6
docker run -dit --name mongo --hostname mongo mongo:3.6 --bind_ip_all --replSet rs0

Do you support such a feature? I can’t find it anywhere. Or is it possible to solve by building a custom docker. I’ve built several dockers for CCI but I don’t know how to achieve this with mongo…


#2

What approach are you using to run that image presently?


#3

We want to start using Mongo 3.6 change streams in our tests. We run it only from the command line now. What we need is to switch to ReplicaSets in CircleCI as we can do it locally and in production too.


#4

OK. Well, the trivial way to run images in Circle is to add them to the docker key in your config file. For example, this is what I have for the Docker image:

jobs:
  build:
    working_directory: /app
    docker:
      - image: docker:17.05.0-ce-git

You can put many images here, and they will all be spun up - the first one becomes the base in which all subsequent commands are run, but it can communicate with the others. You may be able to do that, and pass commands in YAML subkeys (read the docs to see - I don’t know as I don’t use this option).

If not, you can spin up this image using the docker run command you have mentioned, maybe with the detach option. Or, if you want to spin up a number of images, pull in the images you want, and spin up Docker Compose with a suitable Compose YAML file. You need to be reasonably familiar with Docker and DC for this.


#5

@halfer man, thanks for trying to help but it seems like I didn’t describe want I want to achieve appropriately. :slight_smile: I already wrote several CCI configs. What I don’t know is how to add some command line arguments that would be run together with the docker image.

Now we have:

version: 2
jobs:
  build:
    working_directory: /app

    docker:
      - image: circleci/node:8.4.0
      - image: circleci/mongo:3.5.6

but I would like to include --replSet rs0 to be run with the image:

version: 2
jobs:
  build:
    working_directory: /app

    docker:
      - image: circleci/node:8.4.0
      - image: circleci/mongo:3.5.6 --replSet rs0 # ←←←←←←←←←←←←←←←←←←←← pseudo code ;-]

Have I made my point?


#6

Yes, and I suggested that you might check the documentation, to see if there is switch to allow it. I did a search for you, and found that there is: see this page.


#7

You are great! I couldn’t find that piece!


#8

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.