如何打开文件并读取 Dockerfile 中的内容
我有一个 docker 文件,我需要在其中打开一个文件并获取数据。如果数据是 dev,我将传递一个参数(dev 应用程序),如果它没有将另一个参数(prod 应用程序)传递给 sh 文件。应该是这样的
f=open config.txt
data=f.read()
if data=dev
app=dev application
else
app=prod application
ENTRYPOINT ["./entry.sh app"]
,我试图将参数传递给 .sh 文件 (entry.sh)。这样我就可以在entry.sh 文件中使用传入的参数。请帮助我如何以正确的方式做到这一点。 我是这个 Dockerfile 的新手。
I have a docker file where i need to open a file and get the data .If the data is dev, i am passing a argument(dev application) and if it is not passing another argument(prod application)to the sh file. It should be something like
f=open config.txt
data=f.read()
if data=dev
app=dev application
else
app=prod application
ENTRYPOINT ["./entry.sh app"]
here i am trying to pass the argument to the .sh file (entry.sh).so i can use the incoming argument in the entry.sh file. Please help me how to do it in a correct way.
I am new to this Dockerfile.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在构建 docker 映像时使用 ARG 参数传递参数,如下所示。在构建时,您可以传递诸如 docker build --build-arg ENV_ARG=dev 之类的值
DOCKER FILE CODE SAMPLE
You can pass arguments while building the docker image by using the ARG parameters like this. while building you can pass values like
docker build --build-arg ENV_ARG=dev
DOCKER FILE CODE SAMPLE