Would I have this in a production environment? Absolutely not. But for this test, it is running with these values, yes.
database__client must be set to mysql
database__connection__host should reference the container name of your database container
MYSQL_DATABASE and database__connection__database need to be the same values.
MYSQL_USER and database__connection__user need to be the same values.
MYSQL_PASSWORD and database__connection__password need to be the same values.
But your problem is still one step before that: your Ghost container can’t find your database container. That’s what ERROR Invalid database host is telling you.
To me, this sounds like a classic docker networking problem, though “out of the box” Portainer should take care of this for you.
I’d suggest you enter your Ghost container and try to ping mysql. For me, that worked without issue:
On my docker host I ran this:
sudo docker exec -it test_ghost bash
(the name of the container might differ for you, so look this up in portainer first)
Inside the container:
apt update
apt install -y iputils-ping
ping mysql
(The docker image doesn’t have these utilities installed to keep the size small.)
The output of the last command resulted in something like this:
PING mysql (10.0.111.2) 56(84) bytes of data.
64 bytes from 10.0.111.2 (10.0.111.2): icmp_seq=1 ttl=64 time=0.102 ms
64 bytes from 10.0.111.2 (10.0.111.2): icmp_seq=2 ttl=64 time=0.117 ms
64 bytes from 10.0.111.2 (10.0.111.2): icmp_seq=3 ttl=64 time=0.108 ms
^C
--- mysql ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 0.102/0.109/0.117/0.006 ms
This confirms that the Ghost container can indeed see the host mysql – now the question is…can yours?
Just for reference, I again copied the exact setup you played back here, pasted it into my Portainer, and it’s running: