Answer the question
In order to leave comments, you need to log in
Why won't mysql start in a docker container?
Hello!
Here is the content of my Dockerfile. Its task is to deploy apache + php + mariadb (and yes, I need the database to be in this container).
FROM php:7.3-apache
RUN apt-get update -y && apt-get install -y \
curl \
wget \
git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libzip-dev \
libxml2 libxml2-dev \
&& docker-php-ext-install iconv \
&& docker-php-ext-install mbstring \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install gd \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install zip \
&& docker-php-ext-install opcache \
&& docker-php-ext-install soap
RUN echo "\
short_open_tag = On\n\
display_errors = On\n\
error_log = /var/log/php/error.log\n\
error_reporting = E_ALL ^ E_DEPRECATED\n\
log_errors = On\n\
display_startup_errors = On\n\
cgi.fix_pathinfo = 0\n\
date.timezone = Europe/Moscow\n\
mbstring.func_overload = 2\n\
mbstring.internal_encoding = UTF-8\n\
max_input_vars = 10000\n\
post_max_size = 1024M\n\
memory_limit = 512M\n\
upload_max_filesize = 1024M\n\
max_execution_time=60\n\
extension=mcrypt" > /usr/local/etc/php/php.ini
RUN a2enmod rewrite
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
&& ln -sf /dev/stderr /var/log/apache2/error.log
RUN groupadd -r mysql && useradd -r -g mysql mysql
RUN apt-get install -y mariadb-server mariadb-client
RUN /etc/init.d/mysql start && \
mysql -u root -e "CREATE DATABASE web"
RUN mkdir /root/.ssh/
ADD id_rsa /root/.ssh/id_rsa
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
EXPOSE 80 443
CMD ["/etc/init.d/mysql", "start"]
CMD ["apachectl", "-DFOREGROUND"]
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question