我正在尝试包含我们的cakephp 3应用。我也尝试使用phpmyadmin图像并将其连接到mysql图像但是当我尝试登录到phpmyadmin时,我在该页面上收到错误。
mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name does not resolve
mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve
我不确定我的代码有什么问题。我希望你能提供帮助。这是我的Dockerfile:
FROM php:7.1.5-apache
RUN apt-get update && apt-get install -y \
libicu-dev \
libpq-dev \
libmcrypt-dev \
mysql-client \
git \
zip \
unzip \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-install \
intl \
mbstring \
mcrypt \
pcntl \
pdo_mysql \
pdo_pgsql \
pgsql \
zip \
opcache
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
ENV APP_HOME /var/www/html
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
RUN sed -i -e "s/html/html\/webroot/g" /etc/apache2/sites-enabled/000-default.conf
RUN a2enmod rewrite
COPY . $APP_HOME
RUN composer install --no-interaction
RUN chown -R www-data:www-data $APP_HOME
CMD ["apache2", "-DFOREGROUND"]
这是我的docker-compose.yml文件:
version: '2'
services:
cakeblog:
build: .
ports:
- "4000:80"
depends_on:
- mysql
links:
- mysql
volumes:
- ".:/var/www/html/"
environment:
- SECURITY_SALT=ashg4543323dd3434343434dsddet556kk
- MYSQL_URL=mysql
- MYSQL_USERNAME=root
- MYSQL_PASSWORD=test
mysql:
image: mysql:5.7
container_name: phpmyadmin_mysql
volumes:
- mysql_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_DATABASE=cakeblog
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
links:
- mysql:db
depends_on:
- mysql
ports:
- "8080:80"
environment:
- PMA_ARBITRARY=1
- TESTSUITE_PASSWORD=test
volumes:
mysql_data:
答案 0 :(得分:0)
此问题的原因可能是docker-compose.yml文件中MySQL映像规范的错误位置。
试试这个。
version: '2'
services:
mysql:
image: mysql:5.7
container_name: phpmyadmin_mysql
volumes:
- mysql_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_DATABASE=cakeblog
cakeblog:
build: .
ports:
- "4000:80"
depends_on:
- mysql
links:
- mysql
volumes:
- ".:/var/www/html/"
environment:
- SECURITY_SALT=ashg4543323dd3434343434dsddet556kk
- MYSQL_URL=mysql
- MYSQL_USERNAME=root
- MYSQL_PASSWORD=test
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
links:
- mysql:db
depends_on:
- mysql
ports:
- "8080:80"
environment:
- PMA_ARBITRARY=1
- TESTSUITE_PASSWORD=test
volumes:
mysql_data: