Docker Debian:错误 2002(HY000):无法通过套接字“/run/mysqld/mysqld.sock”连接到本地服务器(111)

Docker Debian:错误 2002(HY000):无法通过套接字“/run/mysqld/mysqld.sock”连接到本地服务器(111)

在 Debian 12 容器上:我遇到错误 2002 (HY000):无法通过套接字“/run/mysqld/mysqld.sock”(111) 连接到本地服务器。

mariadb 服务已启动但是不起作用。

这是我的 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 错误 2002 (HY000): 无法通过套接字“/run/mysqld/mysqld.sock”连接到本地服务器 (111)


Dockerfile:42

相关内容