只是基本和简单的步骤说明了我的尝试:
- docker pull mysql/mysql-server
- sudo docker run -i -t mysql/mysql-server:latest/bin/bash
- yum 安装 vi
- vi/etc/my.cnf -> bind-address=0.0.0.0
- 退出
- docker
- docker commit new_image_name
- docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -d new_image_name
docker ps -a 状态 - 退出 (1)
请告诉我我做错了什么。
最佳答案
与其尝试修改现有图像,不如尝试使用(用于测试)MYSQL_ROOT_HOST=%
。
这将允许从任何 IP 进行 root 登录。 (如 docker-library/mysql issue 241 中所见)
sudo docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_ROOT_HOST=% -d mysql/mysql-server:latest
README
提到:
By default, MySQL creates the
'root'@'localhost'
account.
This account can only be connected to from inside the container, requiring the use of thedocker exec
command as noted under Connect to MySQL from the MySQL Command Line Client.
To allow connections from other hosts, set this environment variable.
As an example, the value "172.17.0.1
", which is the default Docker gateway IP, will allow connections from the Docker host machine.
关于docker - 提交更改后无法运行容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44475975/