我试图运行一个测试WordPress博客使用无根的Podman containers。
我尝试了这些教程的许多变体:
https://www.linuxwave.info/2020/12/installing-wordpress-using-podman.html
https://www.linkedin.com/pulse/podman-vs-docker-deploying-wordpress-application-kritik-sachdeva
它总是结束在WordPress通信(显示在网站上,而不是CLI)Error establishing a database connection
。
我正在使用VPS / Ubuntu 22.04。让我向您展示一下我的配置:
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
容器已启动并运行
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看起来正常:
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正在运行
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.
我觉得wordpress容器和mysql容器之间的通信有问题,但是我试了很多方法都没能调试出来,请提示我如何调试这个问题。
编辑:
我设法连接,但访问被拒绝:我使用了podman网络教程中的想法
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
现在它结束在mariadb拒绝连接。
2022-11-11 21:50:29 9 [Warning] Access denied for user 'mywpuser'@'10.0.2.100' (using password: YES)
我得进一步调查
1条答案
按热度按时间5t7ly7z51#
你最初的尝试把他们放在一个吊舱包含了几个小错误。
下面是与工作版本的差异。
首先-pod中的容器都共享localhost地址,所以你可以将其用于主机。注意-“localhost”用于表示带有mysql的unix套接字,而不是实际的网络,你需要的是IP地址。
其次,您在设置密码的变量中漏掉了一个“S”。
这样做,如果它不工作,立即执行
podman pod restart myblog
。