Is MongoDB really supported?

It seems a lot of people have trouble with MongoDB. My particular issue right now is that I can’t get the container to stay up so that my NodeJS app can connect to it. I have tried specifying the ports as in the posts below, and I get “extraneous key not permitted.” Even without them, I get Build was cancelled. I have not tried removing the MONGO_INITDB_ environment variables because, well, that’s how my solution is set up, and I feel like any tool that supports MongoDB should support basic Mongo configuration.

There are zero mongo examples in the documentation. Which leads me to my question; is it really supported? It seems like I either have to change my solution’s security model to accommodate very limited functionality, or pick a new database. I’m fine with the second one; not so enthusiastic about the first. Can I bring my own MongoDB container (mongo:4.2.5-bionic) without running into these restrictions? Does Postgres work out of the box? Maybe I’ll head that direction.

Relevant Database Topics:

(“New users can only put two links in a post.” Yuck. There’s a whole list of them, just do a search.)

Here is my config:

version: 2.1
jobs:
  nodejs:
    docker:
      - image: 'circleci/node:latest'
      - image: 'circleci/mongo:latest'
# extraneous key [port] is not permitted
#        port: 27017:27017
# extraneous key [ports] is not permitted
#        ports:
 #          - "27017:27017"
        environment:
          MONGO_INITDB_ROOT_USERNAME: mongoadmin
          MONGO_INITDB_ROOT_PASSWORD: p@ssw0rdToYourMom
    steps:
      - checkout
      - run:
          command: |
            cd node
            ssh-keygen -t rsa -b 4096 -C "fake@email.org" -f ./verbal_rsa -q -N ""
            npm install
            npm build
            npm run start_ci

Every time I start the app, it can’t connect to the mongo container.

I got it working. Apparently I had pointed the connection string to something in my hosts file.

So for anyone paying attention:

  1. “ports”|“port” is no longer supported, and you don’t need it, because the port is automagically exposed for a mongo container.
  2. Yes you can use a different container, you’re not limited to the CircleCI ones.
  3. The environment variables are no longer a problem; a previous post indicated that they were.
  4. “Works on my machine” is still totally a thing.

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