rmoff's random ramblings
about talks

ERROR: Invalid interpolation format for “command” option in service…

Published Nov 20, 2018 by in Docker, Docker-Compose at https://rmoff.net/2018/11/20/error-invalid-interpolation-format-for-command-option-in-service/

Doing some funky Docker Compose stuff, including:

  …
  kafkacat:
    image: confluentinc/cp-kafkacat:latest
    depends_on:
      - kafka
    command: 
      - bash 
      - -c 
      - |
        echo "Waiting for Kafka ⏳"
        cub kafka-ready -b kafka:29092 1 300 && 
        while [ 1 -eq 1 ]
          do awk '{print $0;system("sleep 0.5");}' /data/data.json | \
              kafkacat -b kafka:29092 -P -t purchases
          done        
    volumes: 
      - $PWD:/data
  …

Run it:

$ docker-compose up -d

Oh noes! Error!

ERROR: Invalid interpolation format for "command" option in service "kafkacat": "echo 'Waiting for Kafka'

The cause? $ in the embedded command:

…
do awk '{print $0;system("sleep 0.5");}' /data/data.json | \
…

The fix? Double it up:

  kafkacat:
    image: confluentinc/cp-kafkacat:latest
    depends_on:
      - kafka
    command: 
      - bash 
      - -c 
      - |
        echo "Waiting for Kafka ⏳"
        cub kafka-ready -b kafka:29092 1 300 && 
        while [ 1 -eq 1 ]
          do awk '{print $$0;system("sleep 0.5");}' /data/data.json | \
              kafkacat -b kafka:29092 -P -t purchases
          done        
    volumes: 
      - $PWD:/data

Robin Moffatt

Robin Moffatt works on the DevRel team at Confluent. He likes writing about himself in the third person, eating good breakfasts, and drinking good beer.

Story logo

© 2025