Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose 1.6 "args" attribute on "build"

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.

like image 470
Bmxer Avatar asked Feb 07 '16 22:02

Bmxer


People also ask

How do I pass args to Dockerfile build?

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> .

Does docker compose up do a build?

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).

What is Depends_on in docker compose?

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.

Is docker compose V1 deprecated?

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.


1 Answers

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
like image 191
JesusTinoco Avatar answered Oct 04 '22 04:10

JesusTinoco