我正在使用ubuntu trusty和MariaDB 5.5創建Docker鏡像,但除非實際連接到正在運行的VM,否則我無法啓動MariaDB。MariaDB永遠不會在Docker鏡像中啓動
Dockerfile:
FROM ubuntu:trusty
# Upgrade packages
RUN apt-get update && apt-get upgrade -y
# So we can add a repo to apt
RUN apt-get install -y software-properties-common
# Add MariaDB repo to aptitude
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
RUN add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/5.5/ubuntu trusty main'
RUN apt-get update
# Install MariaDB
RUN DEBIAN_FRONTEND=noninteractive debconf-set-selections << 'mariadb-server-5.5 mysql-server/root_password password PASS'
RUN DEBIAN_FRONTEND=noninteractive debconf-set-selections << 'mariadb-server-5.5 mysql-server/root_password_again password PASS'
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server
# Start MariaDB
RUN service mysql start
# Configure MariaDB User permissions
RUN echo "CREATE USER 'ubuntu'@'localhost'" | mysql -u root
命令我運行後創建:
docker build -t ebth-com-trusty --file `pwd`/Dockerfile `pwd` --no-cache
create命令總是會失敗,因爲:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
但是,如果我註釋掉CREATE USER命令,然後連接到VM,我可以在運行手動後連接MariaDB。
這就好像RUN service mysql start
只是不起作用,我不知道如何進一步調試。
不'運行服務的MySQL start',也許CMD或入口點,而不是 – user2915097
如果你離開了命令,建立圖像和啓動它,你可以進入運行容器並驗證/var/run/mysqld/mysqld.sock中存在的套接字文件 – Ray