引用第一个参数传递给docker entrypoint?

编程入门 行业动态 更新时间:2024-10-22 18:30:41
本文介绍了引用第一个参数传递给docker entrypoint?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试获取我传递给Docker Entrypoint的第一个参数的值。我早些时候收到了一个答案,就如何做到这一点。以下是链接:

I'm trying to obtain the value of the first argument I pass to the Docker Entrypoint. I received an answer earlier on how to do this. Here is the link:

在Docker Entrypoint中引用一个动态参数

所以我设置一个实验,看看是否有效:

So I setup an experiment to see if this works:

这是我的Dockerfile:

Here's my Dockerfile:

FROM alpine:3.3 MAINTAINER ole.ersoy@gmail RUN apk add --update --no-cache --no-progress bash COPY run.sh . ENTRYPOINT /run.sh

而$ code> run.sh entrypoint:

And the run.sh entrypoint:

#!/bin/sh echo The first argument is: $1

然后我建立这个:

docker build -t test .

并运行图像:

ole@MKI:~/docker-test$ docker run test one The first argument is:

我期待:

ole@MKI:~/docker-test$ docker run test one The first argument is: one

想法?

TIA, Ole

TIA, Ole

推荐答案

将ENTRYPOINT更改为下一个:

Change ENTRYPOINT to next:

ENTRYPOINT ["bash", "run.sh"]

它适用于我。在这里阅读更多关于entrypoint参考的 docs.docker/engine/reference/生成器/#entrypoint

It works for me. Read more about entrypoint args here docs.docker/engine/reference/builder/#entrypoint

更多推荐

引用第一个参数传递给docker entrypoint?

本文发布于:2023-11-16 14:28:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第一个   参数   entrypoint   docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!