phpMyAdmin is unable to connect to MySQL server

I am unable to connect to MySQL server, phpMyAdmin an mysql are on two different network. I would like to connect to mysql using PMA_HOST: 172.17.0.1
System OS : Linux/Debian
Here is my docker compose:

services:
  db:
    image: mysql:5.7
    container_name: mysql_local
    volumes:
      - ./db_data:/var/lib/mysql
      - ./my.cnf:/etc/mysql/my.cnf   # Montre ton fichier my.cnf personnalisé
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: db
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    networks:
      - mysql_network  # Réseau pour communication entre les conteneurs

  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin_local
    restart: always
    ports:
      - "8000:80"
    environment:
      PMA_HOST: 172.17.0.1
      PMA_PORT: 3306
      PMA_USER: user
      PMA_PASSWORD: password
    networks:
      - new_network    # Le service phpmyadmin est connecté à new_network aussi

networks:
  mysql_network:
    driver: bridge  # Réseau bridge commun aux deux services
  new_network:
    driver: bridge  # Nouveau réseau bridge

volumes:
  db_data:
    driver: local

I didn’t find any help on the logs.

Docker containers are all about isolation. You place the containers in different Docker networks and still want to connect them? That doesn’t make sense to me.

Same as bluepuma77 : the network is the key. Should be on the same network.

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