如何编写我在Dockerfile中运行参数?(How write I run arguments in Dockerfile?)

我开始

docker run --rm -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl --verbose

我把它放在一个Dockerfile中:

FROM klokantech/tileserver-gl:v2.2.0 ADD . /data

但是我怎样才能在Dockerfile中调用klokantech / tileserver-gl选项“--verbose”?

I start

docker run --rm -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl --verbose

I took this in a Dockerfile:

FROM klokantech/tileserver-gl:v2.2.0 ADD . /data

But how can I call the klokantech/tileserver-gl option "--verbose" in Dockerfile?

最满意答案

如果您的选项“--verbose”是静态的,那么您必须将其作为ENV添加到dockerfile中,

否则,如果您的选项是动态的,那么您必须在dockerfile中使用ARG命令,这样您就可以在构建docker镜像时传递参数而无需更改dockerfile

参考: https : //docs.docker.com/engine/reference/builder/#arg

In case of "klokantech/tileserver-gl --verbose" the argument is used by an implicit startscript on boot of the image. This argument is not in Dockerfile.

docker build -t "test:myimage" . docker run test:myimage --verbose

更多推荐