Hello everyone! I just started dabbling into docker about a few weeks ago. I am trying to create my first dockerfile and having some trouble doing so. It’s a basic ubuntu/trusty container with LAMP. For some reason I get an error when trying to connect to mysql as root during the build process. Here is my dockerfile.
From ubuntu:trusty
MAINTAINER Pepsi "maddog@gmail.com"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y
apache2
mysql-server
php5
php-pear
php5-mysql
php5-curl
php5-gd
wget
unzip
RUN echo “ServerName localhost” >> /etc/apache2/apache2.conf
RUN a2dissite *default
RUN mkdir /var/www/html/lychee
RUN mkdir -p /var/www/html/lychee/public_html
RUN mkdir -p /var/www/html/lychee/log
RUN mkdir -p /var/www/html/lychee/backups
RUN wget -P /var/www/html/lychee/public_html https://github.com/electerious/Lychee/archive/master.zip
RUN unzip /var/www/html/lychee/public_html/master.zip -d /var/www/html/lychee/public_html/
ADD lychee.conf /etc/apache2/sites-available/lychee.conf
RUN a2ensite lychee.conf
RUN a2enmod rewrite
ENV PHP_UPLOAD_MAX_FILESIZE 10M
ENV PHP_POST_MAX_SIZE 10M
RUN service mysql start
RUN mysql -u root
RUN SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘asdf1234’);
RUN flush privileges;
RUN quit;
EXPOSE 80
This is the error I am getting.
Step 17 : RUN service mysql start
—> Running in 97851367fd2e
- Starting MySQL database server mysqld
…done. - Checking for tables which need an upgrade, are corrupt or were
not closed cleanly.
—> 237b6d62bdd6
Removing intermediate container 97851367fd2e
Step 18 : RUN mysql -u root
—> Running in a1214e92f37d
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)
The command ‘/bin/sh -c mysql -u root’ returned a non-zero code: 1