Project

General

Profile

Is it possible to connect wit the docker setup to a database on the same workstation ?

Added by Christian Eichert 3 months ago

I have a docker setup on my workstation, and I was up to connect it to the localhost MySQL database. (like this :)

services:
  redmine:
    image: redmine:alpine
    restart: always
    ports:
      - 80:3000
    environment:
      REDMINE_DB_MYSQL: 127.0.0.1
      REDMINE_DB_PORT: 3306
      REDMINE_DB_USERNAME: redmine
      REDMINE_DB_PASSWORD: redmine
      REDMINE_DB_DATABASE: redmine
      REDMINE_SECRET_KEY_BASE: supersecretkey

I was not successful because the container was trying to connect inside to the 127.0.0.1, respectively to the socket.
what is the right setup for this?


Replies (1)

RE: Is it possible to connect wit the docker setup to a database on the same workstation ? - Added by Pav ata 15 days ago

If by "same workstation" you mean the host system to your containers, then..
To container 127.0.0.1 is its own loopback device.
On Linux host I'd use a docker/podman network (default, I think, is of bridge type) which gives access to the host, then I'd connect Redmine to a newly created - for containers purposes - 'dummy' iface on the host(making sure relevant services, on the host, listen on it and also firewalls are taken into account)

    (1-1/1)