【问题标题】:Command works inside a docker container but fails with docker exec命令在 docker 容器内工作,但 docker exec 失败
【发布时间】:2021-08-18 03:03:15
【问题描述】:

我正在使用容器化的 Vespa.ai DB,我想从主机执行以下命令:

  1. vespa 停止服务
  2. vespa 删除索引
  3. vespa 启动服务

如果我在附加容器后从我的 shell 中执行以下vespa-stop-services && vespa-remove-index && vespa-start-services,它可以正常工作。但是当我使用 docker exec 时它失败了。

我尝试了以下命令:

docker exec bash -c 'vespa-stop-services && vespa-remove-index && vespa-start-services'

docker exec bash -l 'vespa-stop-services && vespa-remove-index && vespa-start-services'

我成功执行这些命令的唯一方法是按顺序执行它们,我想避免这种情况:

docker exec bash -l 'vespa-stop-services'

docker exec bash -l 'vespa-remove-index'

docker exec bash -l 'vespa-start-services'

我做错了什么? 提前致谢!

【问题讨论】:

  • 输出是什么?您可以通过添加完整的日志/命令来编辑问题吗?

标签: docker vespa docker-exec


【解决方案1】:

从父主机系统运行时需要指定这些命令的位置

以下工作/应该工作:

docker exec vespa bash -c "/opt/vespa/bin/vespa-stop-services && /opt/vespa/bin/vespa-remove-index -force && /opt/vespa/bin/vespa-start-services"

注意-force,它不会在删除数据之前要求确认,还要注意索引不是唯一的持久数据,仍然保留配置状态。

名为“vespa”的 docker 容器的示例运行:

docker exec vespa bash -c "/opt/vespa/bin/vespa-stop-services && /opt/vespa/bin/vespa-remove-index -force && /opt/vespa/bin/vespa-start-services"
Executing /opt/vespa/libexec/vespa/stop-vespa-base.sh
config-sentinel was running with pid 7788, sending SIGTERM
Waiting for exit (up to 15 minutes)
.. DONE
configproxy was running with pid 7666, sending SIGTERM
Waiting for exit (up to 15 minutes)
. DONE
[info] You have 23088 kilobytes of data for cluster msmarco
[info] For cluster msmarco distribution key 0 you have:
[info] 23084 kilobytes of data in var/db/vespa/search/cluster.msmarco/n0
[info] removing data:  rm -rf var/db/vespa/search/cluster.msmarco/n0
[info] removed.

Running /opt/vespa/libexec/vespa/start-vespa-base.sh
Starting config proxy using tcp/localhost:19070 as config source(s)
runserver(configproxy) running with pid: 10553
Waiting for config proxy to start
config proxy started after 1s (runserver pid 10553)
runserver(config-sentinel) running with pid: 10679

【讨论】:

    猜你喜欢
    • 2019-04-28
    • 2021-08-09
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多