docker编译命令。服务中 "command "选项的无效插值格式。

问题描述 投票:1回答:1

在我的docker编译中,我有以下命令。

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'

等到mock -server启动后再运行后台的启动命令

  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

但我得到以下错误。

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

bash docker docker-compose
1个回答
1
投票

你需要转义 $$$

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'

这应该可以解决 构建问题

© www.soinside.com 2019 - 2024. All rights reserved.