Docker Community Forums

Share and learn in the Docker community.

Connecting from php to mysql in Docker

I am starting with docker and have some problems to make the right config. The Framework need a script to make the backend working. This needs a sql connection. I found a way to make phpmyadmin working, but the script can’t connect the mysql database. If someone with more Docker comprehension can give me a tip if something is wrong.

myhomepage-mysql:
  image: mysql:5.7
  container_name: myhomepage-mysql
  environment:
    - MYSQL_ROOT_PASSWORD=toor
    - MYSQL_DATABASE=MyHomepage
    - MYSQL_USER=homepage_admin
    - MYSQL_PASSWORD=admin123

myhomepage-webserver:
  image: phpdockerio/nginx:latest
  container_name: myhomepage-webserver
  volumes:
      - ..:/var/www/myhomepage
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "8080:80"
  links:
   - myhomepage-php-fpm

myhomepage-php-fpm:
  build: .
  dockerfile: php-fpm/Dockerfile
  container_name: myhomepage-php-fpm
  volumes:
    - ..:/var/www/myhomepage
    - ./php-fpm/php-ini-overrides.ini:/etc/php/7.1/fpm/conf.d/99-overrides.ini
  links:
    - myhomepage-mysql

myhomepage-phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: myhomepage-phpmyadmin
    environment:
        PMA_USER: root
        PMA_PASSWORD: toor
        PMA_HOST: mysql
        MYSQL_ROOT_PASSWORD: toor
    ports:
        - "8181:80"
    volumes:
       - /sessions
    links:
      - myhomepage-mysql:mysql

Second problem is that phpmyadmin give this message:

Your PHP MySQL library version 10.1.20-MariaDB differs from your MySQL server version 5.7.17. This may cause unpredictable behavior.

Can i access phpmyadmin from http://localhost:8080/phpmyadmin not from http://localhost:8181/ ?