Docker:在Drupal安装期间,链接到mysql容器的Drupal容器无法连接到mysql

编程入门 行业动态 更新时间:2024-10-25 22:35:10
本文介绍了Docker:在Drupal安装期间,链接到mysql容器的Drupal容器无法连接到mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对docker来说还很陌生,我刚刚经历了CMS,以了解它们的配置有多么容易.到目前为止,Wordpress和Joomla都已签出.

I'm fairly new to docker, and I've just been going through the CMS's to see how easy they are to configure. So far, Wordpress and Joomla check out.

当我运行链接到mysql的drupal容器时,我会转到drupal安装屏幕,并在其中显示连接数据库的位置,并使用我的根凭据和数据库主机为"localhost",并在尝试连接时收到错误.我已附上一张图片,向您显示输出. drupal-config-db-output-error

When I run the drupal container linked to mysql, I get to the drupal installation screen and where it says to connect the DB, and I use my root credentials and db host being 'localhost', and receive errors trying to connect. I've attached an image to show you the output.drupal-config-db-output-error

我得到的错误:

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.

任何对此的帮助都会很棒.我试图查看是否可以使用配置文件访问物理卷,但使用Kitematic找不到它们.

Any help on this would be great. I tried to see if I could access the physical the volume with the config files, but I couldn't find them using Kitematic.

谢谢!

推荐答案

以下 docker组成文件将启动Drupal连接到另一个运行Mysql的容器

The following docker compose file will startup Drupal connected to another container running Mysql

db: image: mysql environment: - MYSQL_ROOT_PASSWORD=letmein - MYSQL_DATABASE=drupal - MYSQL_USER=drupal - MYSQL_PASSWORD=drupal volumes: - /var/lib/mysql web: image: drupal links: - db:mysql ports: - "8080:80" volumes: - /var/www/html/sites - /var/www/private

请注意,drupal容器使用 docker链接.这将创建一个名为"mysql"的/etc/hosts条目.运行drupal安装屏幕时,请使用该名称代替"localhost".

Note that the drupal container uses docker links. This will create a /etc/hosts entry called "mysql". Use this instead of "localhost" when running the drupal install screens.

自最初起草此答案以来,docker compose文件语法已更改.

The docker compose file syntax has changed since this answer was originally drafted.

这是更新的语法

version: '2' services: mysql: image: mysql environment: - MYSQL_ROOT_PASSWORD=letmein - MYSQL_DATABASE=drupal - MYSQL_USER=drupal - MYSQL_PASSWORD=drupal volumes: - /var/lib/mysql web: image: drupal depends_on: - mysql ports: - "8080:80" volumes: - /var/www/html/sites - /var/www/private

更多推荐

Docker:在Drupal安装期间,链接到mysql容器的Drupal容器无法连接到mysql

本文发布于:2023-10-18 12:13:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504199.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   连接到   链接   Docker   Drupal

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!