gpt4 book ai didi

python - 如何在 docker 容器中使用参数运行本地主机脚本

转载 作者:行者123 更新时间:2023-12-01 06:41:59 26 4
gpt4 key购买 nike

我正在尝试在 Docker 容器上的 docker 主机中运行本地脚本。

我知道可以使用以下方式运行它: docker exec -i mycontainer bash < mylocal.sh ,但如何使用此方法将参数传递给 mylocal.sh 。

假设我想传递脚本内容以及像 mylocal.sh argument1 这样的参数

我真的不想将文件从主机复制到容器。

最佳答案

您可以使用 -s 选项将参数传递给使用管道的 bash 脚本。

docker exec -i mycontainer bash -s argument1 argument2 < mylocal.sh

关于python - 如何在 docker 容器中使用参数运行本地主机脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59411660/

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