GithubHelp home page GithubHelp logo

Comments (6)

rfay avatar rfay commented on July 19, 2024 1

In places where jq may not be available, use docker-t exec ddev/ddev-utilities jq

from ddev-mongo.

julienloizelet avatar julienloizelet commented on July 19, 2024

Hi @bfuzze , thanks for your message.

Regarding the MONGODB_DB=api, I'm not sure it is still relevant to speak about it in the README. Only source I found mentioning it is "https://api-platform.com/docs/core/mongodb/#enabling-mongodb-support".
@rfay : do you think we could remove this from the README ?

To access a mongodb UI, did you try the provided mongo-express ? (run ddev describe and you will see the url of the mongo-express UI.).

By the way, if your modification is ok for you, you should create a docker-compose.some-name.yaml instead of modifying the docker-compose.mongo.yaml file directly: this way, your modifications won't be lost if you run a ddev get ddev/ddev-mongo and did not remove the #ddev-generated comment.

For example, create a docker-compose.mongo-custom.yaml with just the following content:

services:
    mongo:
      ports:
         - "127.0.0.1:27017:27017"

Thanks

from ddev-mongo.

rfay avatar rfay commented on July 19, 2024

in order to make the instance accessible outside of DDev environments

Are you saying that you want a process on the host to access your mongo-in-container ?

Mongo uses a non-http protocol, so can't be proxied like HTTP can, so the ddev-router can't be used. So yes, if you're doing this, you'll need to expose the port, and the way you're doing it is correct, but as @julienloizelet says, use a separate override file to do it, and then you won't be preventing your ddev-mongo add-on from ever being upgraded again.

@julienloizelet I agree that MONGODB_DB=api is probably just very misleading to people.

from ddev-mongo.

bfuzze avatar bfuzze commented on July 19, 2024

@rfay

Are you saying that you want a process on the host to access your mongo-in-container ?

That is correct. I have a Node script running outside the container which requires access to the MongoDB instance, so I exposed the port (similar to other db container conventions).

@julienloizelet

For example, create a docker-composer.mongo-custom.yaml with just the following content:...
Perfect. Thanks!

from ddev-mongo.

rfay avatar rfay commented on July 19, 2024

I guess I don't think it's "normal" to add this kind of access, so maybe the docs don't need any update. Note that doing this means that you can't run two projects at the same time that use this, although each could have a different port specified.

from ddev-mongo.

stasadev avatar stasadev commented on July 19, 2024

A small hook (requires jq) to see the connection string without using ports:

hooks:
    post-start:
        - exec-host: echo "Connect to MongoDB with mongodb://db:db@$(docker inspect $(ddev status -j | jq -r .raw.services.mongo.full_name) | jq -r '.[0].NetworkSettings.Networks."ddev-'$(ddev status -j | jq -r '.raw.name')'_default".IPAddress'):27017"

Without jq:

hooks:
    post-start:
        - exec-host: echo "Connect to MongoDB with mongodb://db:db@$(docker inspect $(ddev status -j | docker run -i --rm ddev/ddev-utilities jq -r .raw.services.mongo.full_name) | docker run -i --rm ddev/ddev-utilities jq -r '.[0].NetworkSettings.Networks."ddev-'$(ddev status -j | docker run -i --rm ddev/ddev-utilities jq -r '.raw.name')'_default".IPAddress'):27017"

Can be useful if you don't use mongo-express and want to access the database only from time to time (the IP changes every time you restart the project).

This is something similar to our database scripts (e.g. ddev dbeaver), and can be used to pass this connection string to some program that accepts this syntax.

from ddev-mongo.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.