Passing arguments to python script that is run from "command" in docker-compose.yml

I have 2 python scripts which I am planning to make images of and run them as containers. My docker-compose looks like

version: “2”

services:

publisher1:
  build: pub1
    args:
     - NUMMESSAGE: 10
     - INTERVAL: 0.2
     - MESSAGE: "HelloWorld1"
  command: ["python", "-u", "./publisher1.py"]
  ports:
    - "1234"

publisher2:
  build: pub2
    args:
      - NUMMESSAGE: 20
      - INTERVAL: 0.2
      - MESSAGE: "HelloWorld2"
  command: ["python", "-u", "./publisher2.py"]
  ports:
    - "2222"

Respective Dockerfile(s) do have these arguments mentioned as ARG …

If I indent “args” in docker-compose.yml under “build”, it gives me an error yaml.scanner.ScannerError: mapping values are not allowed here

I did check the space after “args:”, it exists. Still I get the above error.

Also, if I do not indent “args” under “build”, I get the error “unsupported config option for services.publisher1: args”

Migrating the “version” to latest or next, doesn’t help.

Any help will be appreciated.

Thanks,
Sakar

hey
this error occurs when you are using wrong format to write the compose file
SO please check the format is correct.
please read below link for more