引用第一个参数传递给docker entrypoint? [英] Referencing the first argument passed to the docker entrypoint?

查看:1831
本文介绍了引用第一个参数传递给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.com

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参考的 https://docs.docker.com/engine/reference/生成器/#entrypoint

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

这篇关于引用第一个参数传递给docker entrypoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆