以下是我的 Dockerfile 内容:
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN pip install numpy==1.12.0
CMD ["python", "t_1.py", "t_1.json"]
我想在运行时将此文件(t_1.sjon)作为参数传递给 docker run 命令,以便 CMD [“python”,“t_1.py”,“运行时参数”]。我尝试安装卷但失败,因为 json 文件是独立的并且我想要作为参数。
请帮忙。
你应该使用的是ENTRYPOINT
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN pip install numpy==1.12.0
ENTRYPOINT ["python", "t_1.py"]
现在当你运行 docker 命令时
docker run -v ./t_1.json:/data/t_1.json <dockerimage> /data/t_1.json
这将使其等同于python t_1.py /data/t_1.json
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)