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

allow to use $config['db_socket'] #31

Open
ThomasCr opened this issue Mar 26, 2023 · 3 comments
Open

allow to use $config['db_socket'] #31

ThomasCr opened this issue Mar 26, 2023 · 3 comments

Comments

@ThomasCr
Copy link

ThomasCr commented Mar 26, 2023

Hi,

I like to use this container with a mysql installation on the host system.
I mapped /var/run/mysqld/mysqld.sock to the container - db installation was fine, but observium can't access the database.

I think we miss something like in config.php:
$config['db_socket'] = getenv('OBSERVIUM_DB_SOCKET');

So that we can set the env OBSERVIUM_DB_SOCKET=/var/run/mysqld/mysqld.sock

@ThomasCr
Copy link
Author

ok, I found a other workaround. I use host.docker.internal as internal host. Thats my compose file - maybe it is helpful for others.

version: '3'

services:

  observium:
    image: mbixtech/observium:latest
    container_name: observium
    hostname: observium
    environment:
      - OBSERVIUM_ADMIN_USER=admin
      - OBSERVIUM_ADMIN_PASS=abc
      - OBSERVIUM_DB_HOST=host.docker.internal
      - OBSERVIUM_DB_NAME=observium
      - OBSERVIUM_DB_USER=observium 
      - OBSERVIUM_DB_PASS=abc
      - OBSERVIUM_BASE_URL=http://zentrale.home.lan:8888
      - TZ=Europe/Berlin
    volumes:
      - type: bind
        source: /var/run/mysqld/mysqld.sock
        target: /var/run/mysqld/mysqld.sock
      - observium-logs:/opt/observium/logs
      - observium-rrd:/opt/observium/rrd
    network_mode: 'bridge'
    ports:
      - "8888:80"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    restart: unless-stopped

volumes:
  observium-logs:
    name: observium-logs
  observium-rrd:
    name: observium-rrd

But I leave the issue open, because socket access is more powerful.

@somsakc
Copy link
Owner

somsakc commented Jan 1, 2024

I did some research and found the extra impact to observium-init.sh file. Consequently, I could not merge this request into the repository yet. Hopefully, I will get the proper solution to fulfill your request in future.

@r-daneel
Copy link
Contributor

Hi @ThomasCr,

Why can't you just map the connexion to your host's IP or hostname directly ?
AFAIK, if your host's database listens on the appropriate interface (even docker0 for instance), connecting to it would require no specific arrangement within the container.

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