docker build with --build-arg 带有多个参数多个、参数、build、docker

2023-09-06 18:24:12 作者:风雪夜归人

根据文档,可以为标志 --build-arg 定义多个参数,但我不知道如何.我尝试了以下方法:

According to the documentation, it's possible to define multiple args for the flag --build-arg, but I can't find out how. I tried the following:

docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5 number_of_replicas=2 --no-cache .

=> 这会返回一个错误.

=> This returns an error.

我也试过了:

docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5,number_of_replicas=2 --no-cache .

=> 这会将一个变量 number_of_shards 设置为值5,number_of_replicas=2"

=> This sets one variable, number_of_shards, to the value "5,number_of_replicas=2"

知道如何定义多个参数吗?

Any idea how I can define multiple arguments?

推荐答案

对每个参数使用 --build-arg.

如果您要传递两个参数,请在每个参数中添加 --build-arg,例如:

If you are passing two argument then add --build-arg with each argument like:

docker build 
-t essearch/ess-elasticsearch:1.7.6 
--build-arg number_of_shards=5 
--build-arg number_of_replicas=2 
--no-cache .