当停机/未启动时,如何编辑码头容器中的文件 [英] How can I edit files in a docker container when it's down/not-started

查看:176
本文介绍了当停机/未启动时,如何编辑码头容器中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用例:我开始了一些漂亮的码头图像,我的容器需要一些玩耍(配置文件更改用于研究)。我编辑一个文件(使用sed或vim ;-)),然后我停止容器并尝试启动它。现在我在配置中发生错误,并且docker容器在我执行时不会出现: docker restart< my-container-id / -name> 如何编辑配置文件来解决错误?

Use-case: I started some nice docker image and my container needs some playing around (configuration file changes for research). I edit a file (using sed or vim ;-) ) and then I stop the container and try to start it. Now I made a mistake in the configuration and the docker container does not come up when I do: docker restart <my-container-id/-name> How can I edit the configuration-file to fix the mistake?

推荐答案

根据 jpetazzo (见 https://github.com/jpetazzo/nsenter/issues/27#issuecomment-53799568 )我启动了一个使用原始容器的卷的不同容器。以下是如何:

Based on the advice of jpetazzo (see https://github.com/jpetazzo/nsenter/issues/27#issuecomment-53799568) I started a different container that used the 'volumes' of the original container. Here is how:

docker run --volumes-from <my-container-id/-name> -it busybox

这将启动一个busybox shell。在那里,您有vi和其他工具来检查和修复配置文件。

This will start a busybox shell. In there you have vi and other tools to inspect and fix the configuration-files.

这篇关于当停机/未启动时,如何编辑码头容器中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆