[英]HHVM inside Docker and MySQL (outside) on host
我使用以下配置在cPanel服務器上的Docker內設置HHVM:
部分- “如何在cPanel的Ubuntu Docker容器中運行HHVM”
我的Docker配置為:
"Name": "/sad_wozniak",
"NetworkSettings": {
"Bridge": "docker0",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.13",
"IPPrefixLen": 16,
"MacAddress": "02:42:ac:11:00:0d",
"PortMapping": null,
"Ports": {
"9000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9000"
並在域的VirtualHost上添加:
<IfModule mod_proxy_fcgi.c>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://172.17.0.13:9000/home/username/public_html/
</IfModule>
我檢查它是否可以卷曲:
HTTP/1.1 200 OK
Date: Sat, 04 Apr 2015 22:34:52 GMT
Server: Apache
X-Powered-By: HHVM/3.6.1
X-Mod-Pagespeed: 1.9.32.3-4448
Cache-Control: max-age=0, no-cache
Content-Length: 17
Content-Type: text/html; charset=utf-8
但我得到MySQL錯誤:
Error establishing a database connection
外部Docker MySQL服務器有權使用任何遠程連接。 我想在服務器上對MySQL服務器使用“ localhost”。
MySQL運行在:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 498 19250361 3206/mysqld
如何將HHVM與Docker外部的MySQL連接?
如文檔所述,您需要將主機地址作為別名添加到容器
http://docs.docker.com/reference/commandline/cli/#adding-entries-to-a-container-hosts-file
Note: Sometimes you need to connect to the Docker host, which means getting the IP address of the host. You can use the following shell commands to simplify this process:
$ alias hostip="ip route show 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print \$2 }'"
$ docker run --add-host=docker:$(hostip) --rm -it debian
之后,您應該能夠從容器使用地址docker:3306
連接到主機MySQL。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.