I am trying to run a test Wordpress blog using rootless Podman conteiners.
I tried many variations of those tutorials:
https://www.linuxwave.info/2020/12/installing-wordpress-using-podman.html
https://www.linkedin.com/pulse/podman-vs-docker-deploying-wordpress-application-kritik-sachdeva
It always ends up in Wordpress communicate (displayed on website, not CLI) Error establishing a database connection
.
I am working on VPS / Ubuntu 22.04. Let me show you what my configuration looks like:
podman pod create --name myblog --publish 8080:80
podman run --detach --pod myblog \
-e MYSQL_ROOT_PASSWORD=1234 \
-e MYSQL_DATABASE=mywpdb \
-e MYSQL_USER=mywpuser \
-e MYSQL_PASSWORD=1234 \
--name mywpdb docker.io/library/mysql:8
podman run --detach --pod myblog \
-e WORDPRESS_DB_HOST=mywpdb:3306 \
-e WORDPRESS_DB_NAME=mywpdb \
-e WORDPRESS_DB_USER=mywpuser \
-e WORDPRESS_DB_PASWORD=1234 \
--name mywp docker.io/library/wordpress:6.0
Containers are up and running
ubuntu@vps:~$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
17bc532160f2 k8s.gcr.io/pause:3.5 6 minutes ago Up 5 minutes ago 0.0.0.0:8080->80/tcp 6118c5649aee-infra
186ee1f374db docker.io/library/mysql:8 mysqld 5 minutes ago Up 5 minutes ago 0.0.0.0:8080->80/tcp mywpdb
1ad7071a46a6 docker.io/library/wordpress:6.0 apache2-foregroun... 5 minutes ago Up 5 minutes ago 0.0.0.0:8080->80/tcp mywp
Pod looks ok:
ubuntu@vps:~$ podman pod inspect myblog
{
"Id": "6118c5649aeedb8666b1eeba40679787c1bfa25c33438424191a497b81e823bf",
"Name": "myblog",
"Created": "2022-11-11T20:27:54.388753429Z",
"CreateCommand": [
"podman",
"pod",
"create",
"--name",
"myblog",
"--publish",
"8080:80"
],
"State": "Running",
"Hostname": "",
"CreateCgroup": true,
"CgroupParent": "user.slice",
"CgroupPath": "user.slice/user-libpod_pod_6118c5649aeedb8666b1eeba40679787c1bfa25c33438424191a497b81e823bf.slice",
"CreateInfra": true,
"InfraContainerID": "17bc532160f255750cac00a47e4e2c3cc2597104867ca73d3ff9fc57b896399e",
"InfraConfig": {
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"HostNetwork": true,
"StaticIP": "",
"StaticMAC": "",
"NoManageResolvConf": false,
"DNSServer": null,
"DNSSearch": null,
"DNSOption": null,
"NoManageHosts": false,
"HostAdd": null,
"Networks": null,
"NetworkOptions": null,
"pid_ns": "private",
"userns": "host"
},
"SharedNamespaces": [
"ipc",
"net",
"uts"
],
"NumContainers": 3,
"Containers": [
{
"Id": "17bc532160f255750cac00a47e4e2c3cc2597104867ca73d3ff9fc57b896399e",
"Name": "6118c5649aee-infra",
"State": "running"
},
{
"Id": "186ee1f374dbf052e0da25cce674cd5fc96a6609744ff004455079f5eeeb5e29",
"Name": "mywpdb",
"State": "running"
},
{
"Id": "1ad7071a46a6106900d93269ff94df0fdd8ffc848df74891b1bb0cdeda1cb266",
"Name": "mywp",
"State": "running"
}
]
}
Mysql is running
ubuntu@vps:~$ podman logs mywpdb
2022-11-11T20:28:28.722895Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
I think there is a problem with communication between wordpress container and mysql container, but I failed to debug it, trying many try-hard solutions. Please hint me how to debug this issue.
EDIT:
I managed to connect but access is denied: I used idea from podman networking tutorial
podman run --detach \
-e MYSQL_ROOT_PASSWORD=1234 \
-e MYSQL_DATABASE='mywpdb' \
-e MYSQL_USER='mywpuser' \
-e MYSQL_PASSWORD='1234' \
-p 6969:3306 \
--name mywpdb \
docker.io/library/mariadb:10
podman run --detach \
-e WORDPRESS_DB_HOST='12.12.12.12:6969' \
-e WORDPRESS_DB_NAME='mywpdb' \
-e WORDPRESS_DB_USER='mywpuser' \
-e WORDPRESS_DB_PASWORD='1234' \
-e WORDPRESS_DEBUG=1 \
-p 8080:80 \
--name mywp \
docker.io/library/wordpress:6.0
Now it ends up in mariadb refusing the connection.
2022-11-11 21:50:29 9 [Warning] Access denied for user 'mywpuser'@'10.0.2.100' (using password: YES)
I have to further investigate this
Your original attempt with putting them in a pod contained a couple of small mistakes.
Here is the diff against a working version.
12c12
< -e WORDPRESS_DB_HOST=mywpdb:3306 \
---
> -e WORDPRESS_DB_HOST=127.0.0.1 \
15c15
< -e WORDPRESS_DB_PASWORD=1234 \
---
> -e WORDPRESS_DB_PASSWORD=1234 \
Firstly - containers in a pod all share the localhost address, so you can use that for the host. Note - "localhost" is used to mean the unix socket with mysql rather than actual networking, you want the IP address.
Secondly you missed an "S" from the variable setting your password.
Do that, and if it doesn't work straight away do podman pod restart myblog
.