Docker Shell脚本未按预期参数化

时间:2018-12-13 02:04:21

标签: bash docker

我有以下run.sh脚本:

#!/bin/bash
if [[ "$1" = build ]]
then
    python -m flask run --host=0.0.0.0
else
    echo "$1"
fi

以及以下Dockerfile定义:

FROM python:3
COPY "app.py" /
COPY "requirements.txt" /
COPY "run.sh" /
RUN ["pip", "install", "-r", "requirements.txt"]
RUN ["chmod", "+x", "/run.sh"]
ENV FLASK_APP app.py
EXPOSE 5000
ENTRYPOINT /run.sh
CMD build

./run.sh foo打印出foo,但是docker build . -t test; docker run test打印出空行。怎么会来?

1 个答案:

答案 0 :(得分:2)

对CMD和ENTRYPOINT行使用json / exec语法。否则,docker将使用shell包装命令:

if (menuItem.attr('aria-expanded') === 'true') {
    $(this).attr('aria-expanded', 'false');
} else {
    $(this).attr('aria-expanded', 'true');
    $(this).siblings('li').attr('aria-expanded', 'false');
}

有关两种语法如何相互作用的更多详细信息,请参见table in this documentation