码头组合1.6“args”属性“构建” [英] docker-compose 1.6 "args" attribute on "build"
问题描述
我试图使用新的args属性将变量传递给Dockerfile构建。但是,yaml解析器不接受参数。
错误:yaml.scanner.ScannerError:不允许在此处映射值$ b对于版本2的docker-compose.yml,要求是docker-compose 1.6+和docker-engine 1.10+我们都安装了这两个。
这是我的docker-compose文件的一部分:
:'2'
services:
solr:
build:./solr
args:
solr_port:8983
volumes:
- 。 / apps / solr-conf:/ opt / solr / server / solr
ports:
- 8983:8983
错误是指args行。
解决方案这里的问题是, build
字段应该指定为构建上下文的路径或具有选项的对象,但不是两者。如果要使用 args
字段,则必须在上下文
字段中指定构建路径。
检查以下内容:
版本:'2 '
服务:
solr:
build:
上下文:./solr
args:
solr_port:8983
卷:
- ./apps/solr-conf:/opt/solr/server/solr
ports:
- 8983:8983
I'm trying to use the new "args" attribute to pass variable to Dockerfile build. But the yaml parser is not accepting the parameter.
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
For version 2 of docker-compose.yml the requirements are docker-compose 1.6+ and docker-engine 1.10+ and I have both them installed.
This is part of my docker-compose file:
version: '2'
services:
solr:
build: ./solr
args:
solr_port: 8983
volumes:
- ./apps/solr-conf:/opt/solr/server/solr
ports:
- 8983:8983
The error refers to the "args" line.
解决方案 The issue here is that the build
field should be specified as a path to the build context or as an object with the options, but not both. If you are going to use the args
field, you have to specify the path of your build in the context
field.
Check below how it should be:
version: '2'
services:
solr:
build:
context: ./solr
args:
solr_port: 8983
volumes:
- ./apps/solr-conf:/opt/solr/server/solr
ports:
- 8983:8983
这篇关于码头组合1.6“args”属性“构建”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!