x86dev / docker-ttrss

Tiny Tiny RSS feed reader as a Docker image.
54 stars 41 forks source link

No connection to database #34

Closed reibuehl closed 5 years ago

reibuehl commented 5 years ago

I have setup the postgres db as a container using the following settings in docker-compose:

  ttrssdb:
    container_name: ttrssdb
    image: postgres
    restart: always
    environment:
      - POSTGRES_DB=ttrss
      - POSTGRES_USER=ttrss
      - POSTGRES_PASSWORD=ttrss
      - PGDATA=/pgdata
    volumes:
      - ./volumes/ttrssdb_pgdata:/pgdata

and I use the links directive to connect this container to the ttrss container:

  ttrss:
   container_name: ttrss
   build: ttrss/.
   restart: always
   links:
      - ttrssdb:db
   ports:
      - 127:0.0.1:8080:80
   environment:
      - DB_NAME=ttrss
      - DB_USER=ttrss
      - DB_PASS=ttrss
   depends_on:
      - ttrssdb

but I get errors that the db can't be reached:

ttrss          |        TCP/IP connections on port 5432?</pre>[09:15:21/1249] Spawn interval: 120 sec
ttrss          | <pre>Exception while creating PDO object:SQLSTATE[08006] [7] could not connect to server: Connection refused
ttrss          |        Is the server running on host "localhost" (127.0.0.1) and accepting
ttrss          |        TCP/IP connections on port 5432?
ttrss          | could not connect to server: Address not available
ttrss          |        Is the server running on host "localhost" (::1) and accepting

Am I missing an environment variable? Shouldn't the host "db" be used by ttrss instead of "localhost"?

reibuehl commented 5 years ago

I tried also setting the environment variable DB_HOST=db in the docker-compose.yaml file but that did not make a difference. During startup, I see that it is apparently not used:

ttrss          | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
ttrss          | [s6-init] ensuring user provided files have correct perms...exited 0.
ttrss          | [fix-attrs.d] applying ownership & permissions fixes...
ttrss          | [fix-attrs.d] done.
ttrss          | [cont-init.d] executing container initialization scripts...
ttrss          | [cont-init.d] 50-php: executing...
ttrss          | rm: can't remove '/usr/sbin/php-fpm': No such file or directory
ttrss          | [cont-init.d] 50-php: exited 0.
ttrss          | [cont-init.d] 98-wait-for-db: executing...
ttrss          | Checking database responds within 1s on :5432...
ttrss          | Error: you need to provide a host and port to test.
ttrss          | Usage:
ttrss          |    host:port [-t timeout] [-- command args]
ttrss          |   -q | --quiet                        Do not output any status messages
ttrss          |   -t TIMEOUT | --timeout=timeout      Timeout in seconds, zero for no timeout
ttrss          |   -- COMMAND ARGS                     Execute command with args after the test finishes
yuuki0xff commented 5 years ago

Try setting DB_PORT_5432_TCP_ADDR=ttrssdb to the environment. I experienced the same problem before. This solution is not written in the document, so I think improvement is necessary.

reibuehl commented 5 years ago

@yuuki0xff Do I need one more variable? If I set DB_PORT_5432_TCP_ADDR, the first error is gone and the wait-for-db seems to succeed but later I get errors again about DB_PORT:

ttrss          | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
ttrss          | [s6-init] ensuring user provided files have correct perms...exited 0.
ttrss          | [fix-attrs.d] applying ownership & permissions fixes...
ttrss          | [fix-attrs.d] done.
ttrss          | [cont-init.d] executing container initialization scripts...
ttrss          | [cont-init.d] 50-php: executing...
ttrss          | rm: can't remove '/usr/sbin/php-fpm': No such file or directory
ttrss          | [cont-init.d] 50-php: exited 0.
ttrss          | [cont-init.d] 98-wait-for-db: executing...
ttrss          | Checking database responds within 1s on ttrssdb:5432...
ttrss          | [cont-init.d] 98-wait-for-db: exited 0.
ttrss          | [cont-init.d] 99-ttrss: executing...
ttrss          | Setup: !!! WARNING - No encryption (TLS) used - WARNING    !!!
ttrss          | Setup: !!! This is not recommended for a production server !!!
ttrss          | Setup:                You have been warned.
ttrss          | Setup: Setting up Tiny Tiny RSS (latest revision) ...
ttrss          | Cloning into '/var/www/ttrss'...
ttrss          | Cloning into '/var/www/ttrss/plugins.local/mobilize'...
ttrss          | Cloning into '/var/www/ttrss/plugins.local/feediron'...
ttrss          | Cloning into '/var/www/ttrss/themes.local/levito-feedly-git'...
ttrss          | Cloning into '/var/www/ttrss/themes.local/gravemind-feedly-git'...
ttrss          | Setup: URL is: http://localhost/
ttrss          | Setup: Additional plugins:
ttrss          | Setup: Database
ttrss          | Configuring database for: /var/www/ttrss/config.php
ttrss          | Error: The env DB_PORT does not exist. Make sure to run with "--link mypostgresinstance:DB"
ttrss          | Error: The env DB_PORT does not exist. Make sure to run with "--link mypostgresinstance:DB"
ttrss          | Setup: Applying updates ...
ttrss          | Updating: Tiny Tiny RSS
ttrss          | From https://git.tt-rss.org/git/tt-rss
ttrss          |  * branch            HEAD       -> FETCH_HEAD
ttrss          | Already up-to-date.
ttrss          | Updating: Mobilize plugin
ttrss          | From https://github.com/sepich/tt-rss-mobilize
ttrss          |  * branch            HEAD       -> FETCH_HEAD
ttrss          | Already up-to-date.
ttrss          | Updating: FeedIron
ttrss          | From https://github.com/m42e/ttrss_plugin-feediron
ttrss          |  * branch            HEAD       -> FETCH_HEAD
ttrss          | Already up-to-date.
ttrss          | Updating: Themes
ttrss          | From https://github.com/levito/tt-rss-feedly-theme
ttrss          |  * branch            HEAD       -> FETCH_HEAD
reibuehl commented 5 years ago

I tried also setting DB_PORT and then DB__PORT_5432_TCP_PORT but then I get errors accessing the DB with the username and password provided.

roock commented 5 years ago

@reibuehl did you get it working? for me it is working with the following config:

      - DB_PORT_5432_TCP_ADDR=ttrssdb
      - DB_PORT_5432_TCP_PORT=5432
      - DB_HOST=ttrssdb
      - DB_PORT=5432
      - DB_NAME=ttrss
      - DB_USER=ttrss
      - DB_PASS=ttrss

(also try to remove the links section form the docker-compose setup, it's not required with the correct environment variables)

reibuehl commented 5 years ago

I will try it later. For the moment I have given up and installed tt-rss native on the host.

reibuehl commented 5 years ago

Closing this issue since it seems to be only my local issue.