簡體   English   中英

docker容器中的打開文件已關閉

[英]Open file inside docker container has been shut down

我啟動一個mysql容器並更改容器內的配置文件,在這種情況下為/etc/mysql/my.cnf 並重新啟動容器。

該配置文件可能有問題,容器無法啟動。 容器關閉后如何編輯該配置文件?

容器是不可變的,您的更改和配置都消失了。 您應該使用Dockerfile構建自定義映像並包含my.cnf。

可以輕松完成,創建一個文件夾,在其中創建my.cnf和僅兩行的Dockerfile

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM