programing

MariaDB 도커 이미지 빌드 실패

muds 2023. 9. 8. 21:49
반응형

MariaDB 도커 이미지 빌드 실패

데이터베이스, 테이블, 심플한 값이 포함된 MariaDB 도커 이미지를 구축하려고 합니다.하지만 실패했고 더 나아가 로그를 찾을 수가 없습니다.이것은 내 도커 파일입니다.

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"]

하지만 도커는 예외를 던집니다.

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

이거 어떻게 고쳐요?

언급URL : https://stackoverflow.com/questions/35955635/mariadb-docker-images-build-failed

반응형