docker - 提交更改后无法运行容器

标签 docker

只是基本和简单的步骤说明了我的尝试:

  1. docker pull mysql/mysql-server
  2. sudo docker run -i -t mysql/mysql-server:latest/bin/bash
  3. yum 安装 vi
  4. vi/etc/my.cnf -> bind-address=0.0.0.0
  5. 退出
  6. docker
  7. docker commit new_image_name
  8. 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 the docker 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/

相关文章:

amazon-web-services - Ansible docker_container 'no Host in request URL' , docker pull 工作正常

docker - 运行docker-compose restart是否重新运行init脚本

docker - Jenkins Pipeline docker.build() 给出错误 '"docker build“需要 1 个参数”

linux - WSL2 Ubuntu 20.04 没有 Docker 容器的输出

docker - 在 docker 容器上运行 powershell 或 cmd

nginx - 为什么Docker https-portal的 “See It Work”部分给我一个 “port 443: Connection refused”错误?

使用 Node-RED 作为 Kubernetes 中的服务的 HTTP 端点路由

docker - 基于主机的容器与基于图像的容器

node.js - 如何在 Dockerfile 中将 ruby​​ :3. 0.1-alpine3.13 镜像的 Node 版本设置为 16.x

oracle - 在Docker容器中安装Oracle数据库