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.
If you want to pass multiple build arguments with docker build command you have to pass each argument with separate — build-arg. docker build -t <image-name>:<tag> --build-arg <key1>=<value1> --build-arg <key2>=<value2> .
Description. Builds, (re)creates, starts, and attaches to containers for a service. Unless they are already running, this command also starts any linked services. The docker compose up command aggregates the output of each container (like docker compose logs --follow does).
depends_on is a Docker Compose keyword to set the order in which services must start and stop. For example, suppose we want our web application, which we'll build as a web-app image, to start after our Postgres container.
Compose V1 is marked as deprecated, and we'll begin patching only high-severity vulnerabilities or fixing critical bugs until the next milestone. Developers can continue to alias docker-compose to use docker compose.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With