1

I have a customized Apache2/PHP container that I want to link to my MySQL one.

Both containers are running via Rancher.

The Dockerfile that created the image fro the Apache2 container looks like this:

FROM ubuntu:latest

RUN apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install \
    apache2 php7.0 php7.0-mysql libapache2-mod-php7.0 curl lynx-cur libpng-dev curl libcurl4-openssl-dev

RUN docker-php-ext-install mysql mysqli pdo pdo_mysql gd curl

RUN a2enmod php7.0
RUN a2enmod rewrite

RUN service apache2 restart

This container runs a Yii 1 application, which runs just fine on a regular undockerized LAMP stack. This container is simply liked via Rancher to a regular mysql:latest container. I also have an phpmyadmin container that just connects fine to that. I checked the permissions and passwords of the user that is supposed to connect to the mysql container like a 1000 times and they seem to be fine.

Nevertheless, I always get an Yii CDbConnection failed to open the DB connection.

The error I get (looking at the log files) is the following:

SQLSTATE[HY000] [2002] No such file or directory

1 Answer 1

1

I found the issue (combination of different things):

  • www-data had not read/write access
  • The image was changed to php:7.0-apache
  • Removed mysql from the docker-php-ext-install
  • I found out that my config file was not correct (it referenced db-address localhost, it was set to the link name)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.