Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose command: Invalid interpolation format for "command" option in service

In my docker compose I have the following command:

command: bash -c 'while [[ "$(curl --connect-timeout 2 -s -o /dev/null -w ''%{http_code}'' https://mock-server:4000/readiness)" != "200" ]]; do echo ..; sleep 5; done; echo backend is up; npm start'

which waits until mock-server is up then run the start command for backend:

  backend:
    build: 
        context: ./test
        dockerfile: Dockerfile
    command: bash -c 'while [[ "$(curl --connect-timeout 2 -s -o /dev/null -w ''%{http_code}'' https://mock-server:4000/readiness)" != "200" ]]; do echo ..; sleep 5; done; echo backend is up; npm start'
    ports: 
      - "3015:3015"
    depends_on:
      - couchdb
      - redis
      - mock-server
    user: root

But I get the following error:

ERROR: Invalid interpolation format for "command" option in service "backend": "bash -c 'while [[ "$(curl --connect-timeout 2 -s -o /dev/null -w ''%{http_code}'' https://uds-mock-server:4000/readiness)" != "200" ]]; do echo ..; sleep 5; done; echo backend is up;; npm start'"

I cannot see what is wrong with my command. any help is appreciated

like image 344
Learner Avatar asked Dec 03 '19 13:12

Learner


1 Answers

You need to escape the $ with $$

command: bash -c 'while [[ "$(curl --connect-timeout 2 -s -o /dev/null -w ''%{http_code}'' https://mock-server:4000/readiness)" != "200" ]]; do echo ..; sleep 5; done; echo backend is up; npm start'


command: bash -c 'while [[ "$$(curl --connect-timeout 2 -s -o /dev/null -w ''%{http_code}'' https://mock-server:4000/readiness)" != "200" ]]; do echo ..; sleep 5; done; echo backend is up; npm start'

That should fix the build problem

like image 89
nelaaro Avatar answered Nov 12 '22 06:11

nelaaro