[英]How can I pass arguments to a docker container with a python entry-point script using command?
So I've got a docker image with a python script as the entry-point and I would like to pass arguments to the python script when the container is run. 所以我有一个带有python脚本的docker镜像作为入口点,我想在运行容器时将参数传递给python脚本。 I've tried to get the arguments using sys.argv and sys.stdin, but neither has worked. 我试图使用sys.argv和sys.stdin来获取参数,但两者都没有用。 I'm trying to run the container using: 我正在尝试使用以下命令运行容器:
docker run image argument
It depends how the entrypoint was set up. 这取决于入口点的设置方式。 If it was set up in "exec form" then you simply pass the arguments after the docker run
command, like this: 如果它是以“exec form”设置的,那么你只需在docker run
命令之后传递参数,如下所示:
docker run image -a -b -c
If it was set up in "shell form" then you have to override the entrypoint, unfortunately. 如果它是以“shell形式”设置的,那么你不得不重写入口点。
$ docker run --entrypoint echo image hi
hi
You can check the form using docker inspect
. 您可以使用docker inspect
表单。 If the entrypoint appears to begin with /bin/sh -c
, then it is shell form. 如果入口点似乎以/bin/sh -c
开头,则它是shell形式。
References: 参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.