[英]Dockerfile entrypoint script arguments in docker run
My Dockerfile contains a 我的Dockerfile包含一个
RUN xyz.sh --IP localhost
and when I give the command docker run I want to insert a new IP address: 当我给命令docker run时,我想插入一个新的IP地址:
docker run -it IP 127.0.0.1 name:tag
How to pass it like this? 如何通过这样的?
I tried to give ENV in Docker file and using -e in run command but nothing works. 我试图在Docker文件中提供ENV并在run命令中使用-e,但是没有任何效果。
RUN
instructions happen at build time. RUN
指令在构建时发生。
ENTRYPOINT
and CMD
instructions happen at run time. ENTRYPOINT
和CMD
指令在运行时发生。
You probably want something like this in your Dockerfile: 您可能在Dockerfile中需要这样的内容:
....
ENTRYPOINT ["xyz.sh"]
CMD ["--IP", "127.0.0.1"]
....
Then you can run with: 然后,您可以运行:
docker run -it some-image --IP 127.0.0.1
Arguments after the image overwrite the CMD
instruction so then it runs the ENTRYPOINT
instruction followed by your arguments. 映像后的参数会覆盖
CMD
指令,因此它将运行ENTRYPOINT
指令,后跟您的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.