在我的宅基docker容器中缺lessMysql套接字

我有我的应用程序的这个问题

SQLSTATE [HY000] [2002]无法通过套接字'/var/run/mysqld/mysqld.sock'(2)连接到本地MySQL服务器

我使用2个docker容器来托pipe我的laravel 4.2(我认为:o)

这是我的docker-compose.yml

web: image: shincoder/homestead:php5.6 restart: always ports: - "8000:80" # web - "2222:22" # ssh - "35729:35729" # live reload - "9876:9876" # karma server volumes: - ~/.composer:/home/homestead/.composer # composer caching - ~/.gitconfig:/home/homestead/.gitconfig # Git configuration ( access alias && config ) - ~/.ssh:/home/homestead/.ssh # Ssh keys for easy deployment inside the container - ~/apps:/apps # all apps - ~/apps/volumes/nginx/sites-available:/etc/nginx/sites-available # nginx sites ( in case you recreate the container ) - ~/apps/volumes/nginx/sites-enabled:/etc/nginx/sites-enabled # nginx sites ( in case you recreate the container ) links: - mariadb mariadb: image: tutum/mariadb restart: always ports: - "33060:3306" environment: MARIADB_USER: admin # cannot be changed ( for info. only ) MARIADB_PASS: root volumes: - ~/apps/volumes/mysql:/var/lib/mysql # database files 

第一个是使用php5.6的homesteaddocker_web_1,第二个是homesteaddocker_mariadb_1。 我在homesteaddocker_web_1中search了mysql套接字,但是在第二个容器(homesteaddocker_mariadb_1)中find了它,

那么我该如何解决这个问题。

Docker容器与网桥联网。

对于一个容器与另一个容器交谈,您需要链接它们: https : //docs.docker.com/engine/userguide/networking/

如果您的容器需要访问本地networking上的networking资源,则可能需要在--network='host' run命令中使用--network='host'

Interesting Posts