Piwigo, Docker - "Cannot connect to server"

Hi,

after installation with docker-compose, piwigo can’t connect to the db-container.
Is my docker-compose.yml correct?
Do I need to put the port as well in “Host”?

version: "2"
services:

  db:
    image: mysql:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: test
      MYSQL_DATABASE: test
      MYSQL_USER: test
      MYSQL_PASSWORD: test
    volumes:
      - /data_4TB/piwigo/db:/var/lib/mysql

  app:
    image: linuxserver/piwigo
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
    volumes:
      - /data_4TB/piwigo/conf:/config
      - /data_4TB/piwigo/pics:/pictures
    ports:
      - 9988:80
    restart: unless-stopped

give your mysql container a container name and use that as the mysql address

1 Like

same behavior.
do I need some “links”-entry or any other network stuff?

version: "2"
services:

  db:
    image: mysql:latest
    restart: always
    container_name: piwi_db
    environment:
      MYSQL_ROOT_PASSWORD: test
      MYSQL_DATABASE: test
      MYSQL_USER: test
      MYSQL_PASSWORD: test
    volumes:
      - /data_4TB/piwigo/db:/var/lib/mysql

  app:
    image: linuxserver/piwigo
    container_name: piwi_app
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
    volumes:
      - /data_4TB/piwigo/conf:/config
      - /data_4TB/piwigo/pics:/pictures
    ports:
      - 9988:80
    restart: unless-stopped

No, compose by default puts them in the same user defined bridge so they can connect to each other via container name as dns name.

Check the container logs for both

mysql

2020-01-11 09:20:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.,
2020-01-11 09:20:19+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql',
2020-01-11 09:20:19+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.,
2020-01-11 09:20:19+00:00 [Note] [Entrypoint]: Initializing database files,
2020-01-11T09:20:19.630384Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.,
2020-01-11T09:20:19.633262Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 46,
2020-01-11T09:20:30.419385Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.,
2020-01-11 09:20:37+00:00 [Note] [Entrypoint]: Database files initialized,
2020-01-11 09:20:37+00:00 [Note] [Entrypoint]: Starting temporary server,
2020-01-11T09:20:37.705099Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.,
2020-01-11T09:20:37.705399Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 95,
2020-01-11T09:20:38.938566Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.,
2020-01-11T09:20:38.968707Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.,
2020-01-11T09:20:39.026924Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.,
2020-01-11 09:20:39+00:00 [Note] [Entrypoint]: Temporary server started.,
2020-01-11T09:20:39.099112Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock',
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.,
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.,
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.,
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.,
2020-01-11 09:20:47+00:00 [Note] [Entrypoint]: Creating database test,
2020-01-11 09:20:47+00:00 [Note] [Entrypoint]: Creating user test,
2020-01-11 09:20:47+00:00 [Note] [Entrypoint]: Giving user test access to schema test,
,
2020-01-11 09:20:47+00:00 [Note] [Entrypoint]: Stopping temporary server,
2020-01-11T09:20:47.723400Z 14 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.18).,
2020-01-11T09:20:49.787111Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.,
2020-01-11 09:20:50+00:00 [Note] [Entrypoint]: Temporary server stopped,
,
2020-01-11 09:20:50+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.,
,
2020-01-11T09:20:51.367479Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.,
2020-01-11T09:20:51.367770Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 1,
2020-01-11T09:20:52.528490Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.,
2020-01-11T09:20:52.560709Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.,
2020-01-11T09:20:52.631433Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.,
2020-01-11T09:20:52.856659Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

piwigo

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.,
[s6-init] ensuring user provided files have correct perms...exited 0.,
[fix-attrs.d] applying ownership & permissions fixes...,
[fix-attrs.d] done.,
[cont-init.d] executing container initialization scripts...,
[cont-init.d] 01-envfile: executing... ,
[cont-init.d] 01-envfile: exited 0.,
[cont-init.d] 10-adduser: executing... ,
,
-------------------------------------,
          _         (),
         | |  ___   _    __,
         | | / __| | |  /  \ ,
         | | \__ \ | | | () |,
         |_| |___/ |_|  \__/,
,
,
Brought to you by linuxserver.io,
We gratefully accept donations at:,
https://www.linuxserver.io/donate/,
-------------------------------------,
GID/UID,
-------------------------------------,
,
User uid:    1000,
User gid:    1000,
-------------------------------------,
,
[cont-init.d] 10-adduser: exited 0.,
[cont-init.d] 20-config: executing... ,
[cont-init.d] 20-config: exited 0.,
[cont-init.d] 30-keygen: executing... ,
generating self-signed keys in /config/keys, you can replace these with your own keys if required,
Generating a RSA private key,
...................+++++,
...+++++,
writing new private key to '/config/keys/cert.key',
-----,
[cont-init.d] 30-keygen: exited 0.,
[cont-init.d] 40-install: executing... ,
[cont-init.d] 40-install: exited 0.,
[cont-init.d] 99-custom-files: executing... ,
[custom-init] no custom files found exiting...,
[cont-init.d] 99-custom-files: exited 0.,
[cont-init.d] done.,
[services.d] starting services,
[services.d] done.,

This is what I fill in.
I also tried “piwi_db_1” as container name and “db” as given in the compose-file.

Does anyone have a working example to start from?

I could be wrong here, as i’m not sure what this last screenshot you shared is, but
2020-01-11 09:20:47+00:00 [Note] [Entrypoint]: Creating database test
you created a database named test; we also see this in your compose; in this screenshot though, you’ve told it to connect to a database named user…

i changed it during the setup - I figured I can save sme letters :wink:

lol if you do this, you need to comment on it or show us the change; we’re working off what you’re providing :stuck_out_tongue: