MariaDB docker图像构建失败

时间:2016-03-12 08:54:24

标签: mariadb dockerfile

我尝试构建包含数据库,表和简单值的MariaDB docker镜像。但它失败了,而且,我找不到任何日志。这是我的Dockerfile:

FROM centos:centos7 

RUN yum install -y mariadb-server mariadb 
RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql/ 
ADD my.cnf /etc/
RUN sed -i '/[mysqld]/aport=3306' /etc/my.cnf 

RUN \ 
 echo "/usr/bin/mysqld_safe --basedir=/usr &" > /tmp/config && \ 
 echo "cat /var/log/mariadb/mariadb.log" >> /tmp/config && \ 
 echo "mysqladmin -u mysql password 11111" >> /tmp/config && \ 
 echo "mysql -u mysql -p -h localhost test" >> /tmp/config && \
 bash /tmp/config && \ 
 rm -f /tmp/config 

RUN \
 echo "use test" > /tmp/config1 && \
 echo "mysql -e 'GRANT ALL PRIVILEGES ON . TO mysql@localhost IDENTIFIED BY 1111' " >> /tmp/config1 && \ 
 echo "FLUSH PRIVILEGES;" >> /tmp/config1 && \
 bash /tmp/config1 && \ 
 rm -f /tmp/config1 

VOLUME ["/var/lib/mysql"] 
WORKDIR /data 
EXPOSE 3306 
CMD ["/usr/bin/mysqld_safe"]

但是docker会抛出异常

Step 0 : FROM centos:centos7
 ---> bb3d629a7cbc
Step 1 : RUN yum install -y mariadb-server mariadb
 ---> Using cache
 ---> ca601a1b4536
Step 2 : RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql/
 ---> Using cache
 ---> f2ad799ac3ae
Step 3 : ADD my.cnf /etc/
 ---> Using cache
 ---> 44849c37620d
Step 4 : RUN sed -i '/[mysqld]/aport=3306' /etc/my.cnf
 ---> Using cache
 ---> e787b9d14542
Step 5 : RUN echo "/usr/bin/mysqld_safe --basedir=/usr &" > /tmp/config && echo "cat /var/log/mariadb/mariadb.log" >> /tmp/config && echo "mysqladmin -u mysql password hsj7749" >> /tmp/config && echo "mysql -u mysql -p -h localhost **test" >> /tmp/config && bash /tmp/config && rm -f /tmp/config
 ---> Running in 9ecbc5d0fe53
 mysqladmin: connect to server at 'localhost' failed
> error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'**
> Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
> Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
The command '/bin/sh -c echo "/usr/bin/mysqld_safe --basedir=/usr &" > /tmp/config && echo "cat /var/log/mariadb/mariadb.log" >> /tmp/config && echo "mysqladmin -u mysql password hsj7749" >> /tmp/config && echo "mysql -u mysql -p -h localhost test" >> /tmp/config && bash /tmp/config && rm -f /tmp/config' returned a non-zero code: 1

我该如何解决这个问题?

0 个答案:

没有答案