Piwigo Docker 'cannot connect to the server'

Hello all

I know this subject is not new but I want to create a photo server on a Raspi P4, OS Debian Bulleyesnn with Piwigo in a docker container.

I have 2 containers with Piwigo & Mariadb. Boths can communicate with each other but piwigo can’t connect to the server at installation

Here is my docker compose

version: ‘3.9’
services:
piwigo:
image: lscr.io/linuxserver/piwigo:latest
container_name: piwigo
environment:
- PUID=1001
- PGID=1001
- TZ=Europe/London
volumes:
- /mediapiwigo/config:/config
- ${PATH_MEDIA}:/gallery
networks:
- piwigo_network
ports:
- 8000:80
depends_on:
- mariadb
restart: unless-stopped

mariadb:
image: linuxserver/mariadb:latest
container_name: piwigo_db
environment:
- PUID=1001
- PGID=1001
- MYSQL_ROOT_PASSWORD=piwigo
- TZ=Europe/London
- MYSQL_DATABASE=piwigo
- MYSQL_USER=piwigo
- MYSQL_PASSWORD=piwigo
networks:
- piwigo_network
volumes:
- /media/piwigo/mariadb:/config
restart: unless-stopped

networks:
piwigo_network:
external: true

Did I miss something ? Which hostname should I used ?

Thank in advance

I’m progressing :
I’m able to access the hostname when using http://192.168.1.28 but I can’t acess to the database.

any help please ?

Thanks in advance

change the database host to piwigo_db and see if it works. you can’t reach it with what you’re doing because you didn’t publish the ports, so externally, it’s not accessible (external being your LAN) however, since it shared a custom bridge with piwigo, piwigo can access it using docker dns, as long as you use the container_name of mariadb in piwigo.

take a look at
https://www.linuxserver.io/blog/2017-10-17-using-docker-networks-for-better-inter-container-communication
for some more information on how this works.

Thanks Driz for this review.
changing the database host to piwigo_db doesn’t work. :frowning:

I tried to expose port 3306 outside the container but docker “told” this port is already in use by a mariadb instance.
Maybe that’s the issue…

try this
docker exec -it piwigo ping piwigo_db
and tell me the results of that

you shouldn’t NEED to expose the port so it shouldn’t matter

that’s ok
it seems both container can communicate together
media@jarvis:~ $ docker exec -it piwigo ping piwigo_db
PING piwigo_db (172.19.0.2): 56 data bytes
64 bytes from 172.19.0.2: seq=0 ttl=64 time=0.370 ms
64 bytes from 172.19.0.2: seq=1 ttl=64 time=0.302 ms
64 bytes from 172.19.0.2: seq=2 ttl=64 time=0.258 ms
64 bytes from 172.19.0.2: seq=3 ttl=64 time=0.302 ms
64 bytes from 172.19.0.2: seq=4 ttl=64 time=0.255 ms
64 bytes from 172.19.0.2: seq=5 ttl=64 time=0.358 ms

can you clarify what doesn’t work here, since your ping works? Is it the same “cannot connect to the server” error?

i’m going to guess a little based on
image

but where you put root, you should put piwigo which is what you defined as the MYSQL_USER for the piwigo database. You may just be getting a host rejection from trying to login as root here

Hum…until then I had same “cannot connect to server” error .
Now , I have a "504 Gateway Time-out’'…

what are you doing when you get this error? mariadb isn’t a web page so you shouldn’t get anything like this.

for testing, i just spun this up

---
version: "2.1"
services:
  piwigo:
    image: lscr.io/linuxserver/piwigo:latest
    container_name: piwigo
    depends_on:
      - piwigo_db
    environment:
      - PUID=1006
      - PGID=996
      - TZ=Europe/London
    volumes:
      - /tmp/piwigo:/config
      - /tmp/gallery:/gallery
    ports:
      - 8885:80
    restart: unless-stopped
  mariadb2:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: piwigo_db
    environment:
      - PUID=1006
      - PGID=996
      - MYSQL_ROOT_PASSWORD=MYsql1212
      - TZ=Europe/London
      - MYSQL_DATABASE=piwigo
      - MYSQL_USER=piwigo
      - MYSQL_PASSWORD=piwigo
    volumes:
      - /tmp/db:/config
    restart: unless-stopped


after clicking the button

Great !!!
After several trial, I’ve finally able to install Piwigo :

I remove all command relative to network.

The main difference between our decompose file are

  • version “2.1” and "3.9 "
    -dependance between the mariabd & piwigo :
    • You have
      depends_on:
    • “container name” <–piwigo_db
    • This didn’t work on my decompose, I have this :
      depends-on:
    • “name of service” <–mariadb2

Anyway, it’s working now

Here is the final decompose

Many thanks for your awesome support !!!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.