docker icon indicating copy to clipboard operation
docker copied to clipboard

User not created in phpmyadmin when using docker-compose

Open sandwichdreams opened this issue 2 years ago • 6 comments

When I run docker-compose up the container starts and I can log in with root, but no user named phpmyadmin is created. Is there something missing in the yml file?

version: "3.0"

networks:
    dev:

services:
  mariadb:
    image: mariadb:latest
    restart: always
    ports:
      - 3306:3306
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=example
      - MYSQL_USER=mariadb
      - MYSQL_PASSWORD=mariadb
    volumes:
      - /docker/mariadb:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    networks:
      - dev
 
  phpmyadmin:
    image: phpmyadmin:latest
    depends_on:
      - mariadb
    restart: always
    ports:
      - "8080:80"
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_USER=phpmyadmin
      - MYSQL_PASSWORD=phpmyadmin
      - PMA_HOST=mariadb
    volumes:
      - /etc/localtime:/etc/localtime:ro
    networks:
      - dev

sandwichdreams avatar Dec 19 '22 09:12 sandwichdreams

Hi I think youare mistaken, the only user that will be created is by MariaDB container: mariadb

See https://github.com/phpmyadmin/docker/blob/master/testing/docker-compose/docker-compose.testing-one-host.yml as another example

williamdes avatar Dec 19 '22 10:12 williamdes

When I read the documentation, I understand it like this:

If I have the MYSQL_ROOT_PASSWORD variable, phpMyAdmin logs in and creates the user that I entered via MYSQL_USER with the password MYSQL_PASSWORD

If this is not correct. Is there any other variable to implement so I automatically create a user in the phpMyAdmin container?

sandwichdreams avatar Dec 20 '22 08:12 sandwichdreams

If this is not correct. Is there any other variable to implement so I automatically create a user in the phpMyAdmin container?

Actually there is no such feature, I am not sure we should add it. And this variable does not exist, see: https://github.com/phpmyadmin/docker#environment-variables-summary

Where did you see such a configuration?

williamdes avatar Dec 20 '22 09:12 williamdes

You may intend for those variables to be part of your MariaDB container instead.

ibennetch avatar Dec 20 '22 10:12 ibennetch

Where did you see such a configuration?

https://github.com/phpmyadmin/docker#credentials

When reading those lines, I get the impression that the phpmyadmin container uses the root credentials to log in and create a new user with a specific username and password.

rk9qn3j avatar Jan 22 '23 20:01 rk9qn3j

Where did you see such a configuration?

https://github.com/phpmyadmin/docker#credentials

When reading those lines, I get the impression that the phpmyadmin container uses the root credentials to log in and create a new user with a specific username and password.

Okay, maybe we need to clarify that. The two ENVs are not for our container

williamdes avatar Jan 26 '23 08:01 williamdes