D
D
drowzeenico2019-05-16 23:08:05
MongoDB
drowzeenico, 2019-05-16 23:08:05

Is it possible to run local mongo in parallel with mongo launched via docker-compose?

There is a project built from containers and run via docker-compose. One container there is mongodb. Basically, everything works. But the tech lead asked to make this whole system start painlessly, even if a local monga is installed and running on the system.
I decided to do it through an override in the docker-compose.override file. I'm not a docker expert and thought that if you specify other ports than the default mongi port, it will all work. It turned out that ports, instead of rewriting, are concatenated. That is, the conflict remains, the project does not start. But everything works fine if you turn off the local mongo.
Here is docker-compose.yml

version: '3'

services:
  # тут другие контейнеры

  mongo:
    image: mongo:latest
    container_name: 'mongodb'
    environment:
      - MONGO_DATA_DIR=/data/db
    volumes:
      - ./data/db:/data/db
    ports:
      - 27017:27017
    command: mongod --smallfiles --logpath=/dev/null

And here is the override:
version: '3'

services:
  mongo:
    ports:
     - 27001:27017

I expected the container mong to start on port 27001, but it also starts on port 27017, which is already taken by the local db, so docker-compose up --build crashes.
Is it possible to run these two mongs at the same time?
Is it possible to implement this via docker-compose.override?
Am I doing it right? )

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question