Due to the lack of log outputs regarding the issue, I will make a guess: missing grant permission for the user on the database. Make sure that wp-user@% has the grants to actualy access the wordpress database on the host.
The documentation of the image does not mention wheter WORDPRESS_DB_HOST actualy allows IP:PORT or just expects IP (or hostname).
Thanks for your reply. I was able to run wordpress container with flag --net=host and with variable WORDPRESS_DB_HOST=127.0.0.1:3306 and it worked well, but I need to have 9001 port on this container. So the issue is not with variables because they are work. Something with bridge connection or network between container and the host, I think I have some mistake but I can’t understand where exactly it is.
Just to be sure: you do understand what I ment about grants and the effect of --network=host has on it.
This should be a common usecase, and I can assume the forum search should have plenty of hits for it or at least other users that already succeeded with what you try to do.
Since you used the host network, there is no bridge.for your container. Since it doesn’t have a bridge, you can’t forward any port. PHP FPM is listening on the host network, on 127.0.0.1 on port 9000.
Thanks all of you for your replies. I solved this problem by using flag --add-host=host.docker.internal:host-gateway and also changed hostname in WORDPRESS_DB_HOST variable.
Also I maked changes to the file /etc/mysql/mariadb.conf.d/50-server.cnf and changed the string from bind-address = 127.0.0.1 to bind-address = *. After this I executed sudo systemctl restart mysql command and my container worked fine.