Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup docker instance with pre existing postgresql db? #200

Open
AngelouDi opened this issue Dec 13, 2022 · 2 comments
Open

Setup docker instance with pre existing postgresql db? #200

AngelouDi opened this issue Dec 13, 2022 · 2 comments

Comments

@AngelouDi
Copy link

I am trying to setup ctfnote dockerized and connect it to another postgresql db running on a port other than 5432.

I haven't found any way to make it work.

Is there an obvious way I am missing?

@SakiiR
Copy link
Member

SakiiR commented Dec 13, 2022

Hi @AngelouDi,

To achieve this, I think you will need to connect the ctfnote API to the "host network":

https://docs.docker.com/network/host/

This way, the container will share the same network as the host and it will be able to communicate with an external service.

If the database is in the same network as the API, you will just have to modify the environment variable provided to the API container in the docker-compose.yml file.

    environment:
      # [...]
      DB_HOST: db # Change here
      DB_PORT: 5432 # Change here
      WEB_PORT: 3000

@JJ-8
Copy link
Collaborator

JJ-8 commented Dec 15, 2022

I think it is also possible to only map the single host port to port 5432 in the container: https://docs.docker.com/compose/networking/. This way, you don't expose all your host ports to the containers but only the port they require to reach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants