docker容器内的打开文件已被closures

我启动一个mysql容器,并更改容器内的configuration文件,在这种情况下是/etc/mysql/my.cnf 。 并重新启动容器。

可能是错误的configuration文件和容器无法启动。 如何在容器closures时编辑该configuration文件?

一个容器是不变的,你的改变和conf都消失了。 您应该使用Dockerfile来构build自定义图像并包含my.cnf。

它可以很容易地完成,创build一个文件夹,在其中创buildmy.cnf和一个只有两行的Dockerfile

 FROM mysql ADD my.cnf /path/to/mysql/conf/folder # replace with the path where you'd usually put the conf file 

现在build立并运行:

 docker build -t custom_mysql . docker run custom_mysql // << add the run options you need/want (exposed port for example or container name)