gpt4 book ai didi

bash - 找不到Dockerfile CMD的命令

转载 作者:行者123 更新时间:2023-12-02 19:00:34 28 4
gpt4 key购买 nike

我有一个使用的Dockerfile

CMD ['/usr/local/bin/gunicorn', '-b 0.0.0.0:8000', 'myapp.wsgi']

但是当我使用 docker run --rm myimage:latest运行容器时,出现错误:

/bin/sh: 1: [/usr/local/bin/gunicorn,: not found



但是,当我运行 docker run --rm -it myimage:latest /bin/bash进入容器时,我可以看到gunicorn正在运行,并且运行 which gunicorn将返回gunicorn的正确路径。为什么无法运行?

同样,我计划添加
ENTRYPOINT ['/entrypoint.sh']

到我的Dockerfile,但是当我运行它时,我得到了错误

/bin/sh: 1: /bin/sh: [/entrypoint.sh]: not found


entrypoint.sh文件包含:
#! /bin/bash
echo 'Starting app...'
cd /app || exit;
python manage.py migrate;

那么为什么在所有命令都存在时却一直说找不到命令呢?

最佳答案

这里的问题是报价。使用双"引号。

Docker Documentation:

The exec form is parsed as a JSON array, which means that you must use double-quotes (“) around words not single-quotes (‘).



这适用于其他指令,例如RUN,LABEL,ENV,ENTRYPOINT和VOLUME。

关于bash - 找不到Dockerfile CMD的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60733715/

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