How can I pass arguments to a docker container with a python entry-point script using command?

前端 未结 1 566
庸人自扰
庸人自扰 2021-02-11 19:31

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 arg

1条回答
  •  逝去的感伤
    2021-02-11 20:32

    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:

    • http://docs.docker.com/engine/reference/run/#entrypoint-default-command-to-execute-at-runtime
    • http://docs.docker.com/engine/reference/builder/#entrypoint

    0 讨论(0)
提交回复
热议问题