我正在尝试将mysql运行到修改后的ubuntu映像中,其中包括使用以下docker文件安装Node.js和基本的mysql安装
# Memcached
# use the ubuntu base image provided by dotCloud
FROM ubuntu/mysqlbase
MAINTAINER Hitesh
# make sure the package repository is up to dat//e
#RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
#RUN apt-get update
#RUN apt-get install -y mysql-client
#ENTRYPOINT ["wc", "-l"]
#ENTRYPOINT ["echo", "running"]
ENTRYPOINT mysqld_safe & sleep 10
#RUN mysql
RUN echo "[mysqld]" >/etc/mysql/conf.d/docker.cnf
RUN echo "bind-address = 0.0.0.0" >>/etc/mysql/conf.d/docker.cnf
RUN echo "innodb_flush_method = O_DSYNC" >>/etc/mysql/conf.d/docker.cnf
RUN echo "skip-name-resolve" >>/etc/mysql/conf.d/docker.cnf
RUN echo "init_file = /etc/mysql/init" >>/etc/mysql/conf.d/docker.cnf
RUN echo "GRANT ALL ON *.* TO root@'%'" >/etc/mysql/init
USER root
EXPOSE 3306
使用以下命令运行此服务器
sudo docker run -p 3306:13306 mysql/dockerfiletest
遇到以下错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
有人可以建议在这里需要更改的内容。我想使用此容器与其他容器链接,该容器本质上运行我的node.js app。
答案 0 :(得分:2)
UPDATE:您应该检查公开的端口号 - 在您的示例中是memcached(11211)的端口,而不是mysql的端口(3306)。
无论如何,我认为你可能需要修改你的Dockerfile - 在入口点删除不必要的睡眠:
ENTRYPOINT ["/usr/bin/mysqld_safe"]
然后你应该以这种方式启动你的容器(守护进程模式):
root@machine:/# docker run -d -p 3306:<host port> <image id>
答案 1 :(得分:2)
答案已被接受,但我认为如果你改变了&#39;&amp;&#39;到&#39;&amp;&amp;&#39;。不确定docker是否对入口点进行任何解析或只是执行它,但bash对待&#39;&amp;&#39;与&#39;&amp;&amp;&#39;。
完全不同ENTRYPOINT mysqld_safe && sleep 10