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