gpt4 book ai didi

docker - 命令在 docker 容器内工作,但在 docker exec 下失败

转载 作者:行者123 更新时间:2023-12-05 03:41:27 29 4
gpt4 key购买 nike

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

  1. vespa-stop-services
  2. vespa-remove-index
  3. vespa-start-services

如果我在附加容器后从我的 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 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

关于docker - 命令在 docker 容器内工作,但在 docker exec 下失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67763017/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com