如何将文件复制到停止的Docker容器 [英] How to Copy file to stopped docker container

查看:743
本文介绍了如何将文件复制到停止的Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Docker容器中运行elasticsearch.

I am running elasticsearch from within a docker container.

在为ssl配置elasticsearch并屏蔽我的elasticsearch.yml文件时,获得了非法条目,即TAB而不是space.
现在我的Docker容器无法启动并给出以下错误:

While configuring elasticsearch for ssl and shield my elasticsearch.yml file got illegal entry i.e. TAB instead of a space.
Now my docker container is not starting up and giving the following error:

{1.4.4}: Setup Failed ...
- SettingsException[Failed to load settings from [file:/elasticsearch/config/elasticsearch.yml]]
         IOException[Tabs are illegal in YAML.  Did you mean to use whitespace character instead?]
 org.elasticsearch.common.settings.SettingsException: Failed to load
 settings from [file:/elasticsearch/config/elasticsearch.yml]
         at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:947)
         at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromUrl(ImmutableSettings.java:931)
         at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:77)
         at org.elasticsearch.bootstrap.Bootstrap.initialSettings(Bootstrap.java:106)
         at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:177)
         at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)
 Caused by: java.io.IOException: Tabs are illegal in YAML.  Did you
 mean to use whitespace character instead?
         at org.elasticsearch.common.settings.loader.YamlSettingsLoader.load(YamlSettingsLoader.java:44)
         at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:944)
         ... 5 more

如何在不丢失数据或替换现有容器中的elasticsearch.yml文件的情况下编辑elasticsearch.yml或替换它?

How can I edit elasticsearch.yml or replace it without loosing data or replace the elasticsearch.yml file in my existing container?

推荐答案

您可以复制文件,然后再将其复制回容器( 即使容器已停止 )用docker cp $cont_name:/path/in/container /path/on/host复制出来,然后docker cp /path/on/host $cont_name:/path/in/container.

You can copy files out and then back into a container (even when the container is stopped) with the docker cp $cont_name:/path/in/container /path/on/host to copy out and then docker cp /path/on/host $cont_name:/path/in/container.

这篇关于如何将文件复制到停止的Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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