On a Debian 12 container: I have the ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111).
The mariadb service is started but doesn't works.
This is my Dockerfile:
FROM debian:latest
EXPOSE 80/tcp
EXPOSE 3306/tcp
EXPOSE 22/tcp
RUN export LANG=fr_FR.UTF-8
RUN apt clean
RUN apt update
RUN apt install -y curl lsb-release apt-transport-https software-properties-common
RUN add-apt-repository contrib
RUN add-apt-repository non-free
RUN dpkg --configure -a
RUN apt clean
RUN apt update
RUN apt install -y python3.11
RUN rm /usr/lib/python3.11/EXTERNALLY-MANAGED
RUN curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py
RUN mkdir -p /etc/apt/keyrings
RUN curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
RUN curl -sSL https://packages.sury.org/php/README.txt | bash -x
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt clean
RUN apt update
RUN apt upgrade -y
RUN apt install -y openssl python3-cryptography nodejs
RUN apt install -y sudo nano openssh-server apache2 libapache2-mod-fcgid libapache2-mpm-itk php php-fpm php-mbstring php-zip php-intl php-imagick php-mysql php-ps php-bcmath php-bz2 php-cli php-curl php-date php-geoip php-mail php-psr php-xml php-yaml mariadb-server mariadb-client
RUN service apache2 stop
RUN a2dismod mpm_itk php$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
RUN a2dismod mpm_prefork
RUN a2enmod mpm_event
RUN a2enconf php$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")-fpm
RUN a2enmod proxy
RUN a2enmod proxy_fcgi
RUN a2enmod rewrite
RUN npm install -g npm
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
RUN sed -i 's/^bind-address\s*=.*/bind-address = 0.0.0.0/' /etc/mysql/my.cnf
RUN service mariadb start
RUN mysql -u root -e "CREATE USER 'docker'@'%' IDENTIFIED BY 'docker';"
RUN mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'docker'@'%' WITH GRANT OPTION;"
RUN mysql -u root -e "FLUSH PRIVILEGES;"
RUN service mariadb stop
VOLUME /var/www/html
CMD service php$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")-fpm start && service apache2 start && service mariadb start && service ssh start && bash -c "while true; do sleep 3600; done"
[39/42] RUN mysql -u root -e "CREATE USER 'docker'@'%' IDENTIFIED BY 'docker';":
#0 0.243 ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111)
Dockerfile:42