Open file inside docker container has been shut down

烈酒焚心 提交于 2019-12-11 12:23:35

问题


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?


回答1:


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

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

Now build and run:

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


来源:https://stackoverflow.com/questions/36905163/open-file-inside-docker-container-has-been-shut-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!