Here is the command I used to create containers :
docker network create prestashop
docker run -ti --name db --network prestashop -e MYSQL_ROOT_PASSWORD=1234 -p 3307:3306 -d mysql:latest
docker run -ti --name prestashop --network prestashop -e DB_SERVER=db -p 8080:80 -d prestashop/prestashop
With that I can access to the Prestashop installation however when I need to configure the database I get this error :
Database Server is not found. Please verify the login, password and server fields (DbPDO)
I'm using thoses fields :
Database server address : (for this one I tried :) db | 127.0.0.1:3037 | 127.0.0.1
Database name : prestashop
Database login : root
Database password : 1234
And I'm stuck to this step
EDIT :
Tried :
Insert another computer the same commands, everything works until I try to connect from the prestashop database configuration.
Removing the -ti
options from the command line like @balexandre said.
Update
The issue come from the MySQL Version 8. I changed the mysql:latest
to mysql:5.7
and everything is working but this is not the version I'm looking for.
I still have no clue why MySQL 8 doesn't work
First setup the network and his two containers with the following command :
docker network create prestashop
docker run --name db --network prestashop -e MYSQL_ROOT_PASSWORD=1234 -p 3307:3306 -d mysql:latest
docker run --name prestashop --network prestashop -e DB_SERVER=db -p 8080:80 -d prestashop/prestashop
Then if you're using a recent version of prestashop 1.7.* and a MySQL Version 8.*
Connect to your mysql container bash :
docker exec -it db mysql -uroot -p
When you're on the MySQL command line check your users :
SELECT user,plugin,host FROM mysql.user;
+------------------+-----------------------+-----------+
| user | plugin | host |
+------------------+-----------------------+-----------+
| root | caching_sha2_password | |
| mysql.infoschema | caching_sha2_password | localhost |
| mysql.session | caching_sha2_password | localhost |
| mysql.sys | caching_sha2_password | localhost |
| root | caching_sha2_password | localhost |
+------------------+-----------------------+-----------+
To be able to configure your database on your prestashop you need to change the plugin for your root user with empty host
ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'ENTER YOUR PASSWORD';
FLUSH PRIVILEGES;
Everything must work now.