bash 如何在 Dockerfile 中运行脚本文件(.sh 文件)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38264167/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run script file(.sh file) inside Dockerfile?
提问by kalyani chaudhari
I am creating a Docker image. I have 'install.sh' script file and want to run this script file in Dockerfile.
我正在创建一个 Docker 镜像。我有“install.sh”脚本文件,想在 Dockerfile 中运行这个脚本文件。
How should i do this ?
我该怎么做?
回答by kalyani chaudhari
Steps as follows :
步骤如下:
Copy '.sh' file to container
COPY install.sh .
Executing '.sh' file
RUN ./install.sh
将“.sh”文件复制到容器
COPY install.sh .
执行“.sh”文件
RUN ./install.sh
'install.sh' file should be in current working directory else you can specify path.
'install.sh' 文件应该在当前工作目录中,否则您可以指定路径。
回答by anubhava
Inside Dockerfile
, just add call to your script using RUN
command as:
在里面Dockerfile
,只需使用以下RUN
命令添加对脚本的调用:
RUN /path/to/install.sh