且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Docker映像中包含修改后的配置文件?

更新时间:2022-12-06 14:38:22

您无需重新创建整个图像,只需更改一个xml.您可以通过卷或命令替换它.例如,我已经链接了共享文件夹,您可以在容器上运行命令.假设您在/home/share中有Share文件夹,它链接到/c/Share因此,您将新的xml文件放在Share中,容器也可以看到它.接下来,您运行以下命令:

You don't need to create anew the entire image just to change one xml. You can replace it through volumes or command. For example i have linked shared folder and you can run commands on the container. Let say you have Share folder in /home/share and its linked to /c/Share So you put your new xml file in Share and the container can see it too. Next you run this command:

docker exec a5866aee4e90 cp -i /home/share/some.xml /home/the/path/you/chose

Docker exec用于运行命令.您可以使用以下命令进入控制台并运行多个命令:

Docker exec is used to run commands. You can enter the console and run multiple commands with this:

docker exec -it a5866aee4e90 bash