传递参数给python脚本,如何使用命令将参数传递给带有Python脚本脚本的docker容器?...

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. I've tried to get the arguments using sys.argv and sys.stdin, but neither has worked. 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:

docker run image -a -b -c

If it was set up in "shell form" then you have to override the entrypoint, unfortunately.

$ docker run --entrypoint echo image hi

hi

You can check the form using docker inspect. If the entrypoint appears to begin with /bin/sh -c, then it is shell form.

References:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值