gpt4 book ai didi

docker - 带参数的docker容器 `heroku run`命令返回 “not found”

转载 作者:行者123 更新时间:2023-12-02 21:20:02 25 4
gpt4 key购买 nike

我在heroku上运行docker容器,但似乎无法理解其工作方式。

在本地,我可以运行命令docker run imageName ls -al,但是在heroku上:heroku run "ls -al"它返回./entrypoint.sh: line 34: exec: ls -al: not found。虽然当我不带参数运行heroku run ls时,它可以按预期工作。 (作为另一个实验,我先运行了heroku run bash,然后又运行了./entrypoint.sh ls -al)。

这里发生了什么事?

评论更新:

  • Damien MATHIEU:我尝试运行的图像是此https://github.com/jshimko/meteor-launchpad-我的 docker 文件是:
    FROM jshimko/meteor-launchpad:latest 
    CMD ["node", "main.js"]
  • 最佳答案

    编辑2-2017年10月28日

    Heroku的最新更新

    We've triaged this, and we're definitely not implementing Docker-compatible behaviour here. Thanks for catching this - we'll get it fixed.



    原始答案

    从下面可以很清楚地看出您的错误
    ./entrypoint.sh: line 34: exec: ls -al: not found

    您将 ls -al作为一个字符串参数传递。您应该尝试以下
    heroku run -- ls -al

    编辑1

    因此,我创建了一个简单的 Dockerfile来测试该问题。
    FROM alpine
    COPY entrypoint.sh /
    ENTRYPOINT ["/entrypoint.sh"]
    CMD ["tail", "-f", "/dev/null"]

    entrypoint.sh
    #!/bin/sh
    echo "You passed $# arguments"
    for var in "$@"
    do
    echo "$var"
    done

    exec "$@"

    当我在本地构建并运行容器时,输出为
    $ docker run -it 5e866a76fd25
    You passed 3 arguments
    tail
    -f
    /dev/null

    当我将应用程序推送到Heroku时,日志显示如下
    2017-10-21T19:11:11.873567+00:00 app[api]: Deployed web (xxxxx) by user xxx@yyy.com
    2017-10-21T19:11:14.235819+00:00 heroku[web.1]: Starting process with command `tail -f /dev/null`
    2017-10-21T19:11:16.593724+00:00 heroku[web.1]: Process exited with status 127
    2017-10-21T19:11:16.447960+00:00 app[web.1]: You passed 1 arguments
    2017-10-21T19:11:16.447976+00:00 app[web.1]: tail -f /dev/null

    这是完全错误的,因为CMD被发送为单个参数而不是3个参数。我已经和heroku小组一起开了一张票,希望他们能在周二之前答复

    关于docker - 带参数的docker容器 `heroku run`命令返回 “not found”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46850787/

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