简体   繁体   English

Docker 1.12中的Ubuntu 16.10声称MySQL没有套接字

[英]Ubuntu 16.10 in Docker 1.12 claims there is no socket for MySQL

I am now using Docker for Mac and Docker is Docker version 1.12.0-rc4, build e4a0dbc, experimental and I am trying to install MySQL in Ubuntu 16.10. 我现在正在使用Docker for Mac,而Docker是Docker version 1.12.0-rc4, build e4a0dbc, experimental ,我正尝试在Ubuntu 16.10中安装MySQL。 (Do not ask me, why I don't use the official one!) (不要问我,为什么我不使用官方的!)

The installation process is 安装过程是

run Docker 运行Docker

docker run --rm -it ubuntu:16.10

(and install vim) (并安装vim)

update & upgrade apt-get 更新和升级apt-get

apt-get update && apt-get upgrade -y

apt-get mysql-server apt获取mysql服务器

apt-get install -y mysql-server

dump /etc/mysql/my.cnf 转储/etc/mysql/my.cnf

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

dump /etc/mysql/mysql.conf.d/mysqld.cnf 转储/etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
...
[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306

find /var/run/mysqld/mysqld.sock 找到/var/run/mysqld/mysqld.sock

# ls /var/run/
lock  mount  utmp <- there is no "mysqld" directory

Why I am making this mistake for several times and cannot use MySQL... >< 为什么我多次犯此错误并且无法使用MySQL ...> <

If you are trying to access mysql from your host system, your problem is that you aren't exposing port 3306 when you run the ubuntu image: 如果您尝试从主机系统访问mysql,则问题是运行ubuntu映像时没有暴露端口3306:

you need to add this to the run command: 您需要将此添加到运行命令:

docker run --rm -it -p 3306:3306 ubuntu:16.10

Can't imagine why you aren't using one of the usual mysql images, though you'd still have to expose the port. 无法想象为什么您不使用通常的mysql映像之一,尽管您仍然必须公开端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM