docker-observium icon indicating copy to clipboard operation
docker-observium copied to clipboard

allow to use $config['db_socket']

Open ThomasCr opened this issue 2 years ago • 3 comments

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 avatar Mar 26 '23 09:03 ThomasCr

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.

ThomasCr avatar Mar 26 '23 10:03 ThomasCr

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.

somsakc avatar Jan 01 '24 05:01 somsakc

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.

r-daneel avatar Jan 14 '24 17:01 r-daneel