刚接触docker和mysql,想建立一个docker container,里面装个mysql。程序可以直接连接ontainer里的mysql。
这是Dockerfile
FROM ubuntu:14.04
# install mysql
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server
ADD
entrypoint.sh /
entrypoint.sh RUN chmod 755 /
entrypoint.sh ENTRYPOINT ["/
entrypoint.sh"]
EXPOSE 3306
这是`
entrypoint.sh`
#!/bin/bash
mysql -uroot -e 'UPDATE mysql.user SET password=PASSWORD("rootpass") WHERE user="root"'
mysql -uroot -e 'FLUSH PRIVILEGES'
安装的时候好像出了问题,运行`sudo docker build -t test/devenv .`
Setting up mysql-server-5.5 (5.5.38-0ubuntu0.14.04.1) ...
invoke-rc.d: policy-rc.d denied execution of stop.
invoke-rc.d: policy-rc.d denied execution of start.
执行`sudo docker run -d -p 3306:3306 test/devenv`
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2c0bfb09a8a0 test/devenv:latest /
entrypoint.sh /bin/ 7 seconds ago Exited (1) 6 seconds ago berserk_nobel
执行`sudo docker run -i -t ubuntu /bin/bash`
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
大神们我这是要怎么修改?谢谢!
http://stackoverflow.com/questions/24988947/install-mysql-in-docker-and-expose-mysql-service-to-outside
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/124864
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.