码头容器内的打开文件已关闭

码头容器内的打开文件已关闭

本文介绍了码头容器内的打开文件已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I start a mysql container and change the config file inside a container, in this case is /etc/mysql/my.cnf. And restart container.

该配置文件可能有问题,容器无法启动。容器已关闭时,如何编辑配置文件?

Maybe something wrong with that config file and the container cannot start. How can I edit that config file when the container has been shutdown?

推荐答案

容器是不可变的,你的更改和conf已经消失。您应该使用Dockerfile来构建一个自定义图像,并且包含my.cnf。

A container is immutable, your changes and conf are gone. You should use a Dockerfile to build a custom image and include my.cnf.

可以轻松完成,创建一个文件夹,在其中创建my.cnf和一个Dockerfile只有两行

It can be easily done, create a folder, create my.cnf in it and a Dockerfile with only two lines

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

现在构建并运行:

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

这篇关于码头容器内的打开文件已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 19:53