How to pass arguments to Shell Script through docker run

后端 未结 7 1926
灰色年华
灰色年华 2020-11-30 17:49

I am new to the docker world. I have to invoke a shell script that takes command line arguments through a docker container. Ex: My shell script looks like:

#         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 18:25

    with this script in file.sh

    #!/bin/bash
    echo Your container args are: "$@"
    

    and this Dockerfile

    FROM ubuntu:14.04
    COPY ./file.sh /
    ENTRYPOINT ["/file.sh"]
    

    you should be able to:

    % docker build -t test .
    % docker run test hello world
    Your container args are: hello world
    

提交回复
热议问题