docker / dev-environments

60 stars 32 forks source link

Compose project gives error for escaping $ for mongo replica set even though it already is? #117

Closed joezappie closed 1 year ago

joezappie commented 2 years ago

Describe the bug I'm trying to use a mongo replica set in my dev environment. This typically is done by using the healthcheck to run the "rs.initiate()" command for mongo. When running docker-compose up manually it works fine, but when run through dev-enviroments I get an error about escaping a $.

My docker-compose.yaml is this:

version: "3.7"
services:
  mongodb:
    hostname: mongodb
    container_name: mongodb
    image: mongo:5.0.9
    environment:
      MONGO_INITDB_DATABASE: zyphox
      MONGO_REPLICA_SET_NAME: rs0
    volumes:
      - mongo-data:/data/db
    expose:
      - 27017
    ports:
      - "27017:27017"
    restart: always
    entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    healthcheck:
      test: test $$(echo "rs.initiate().ok || rs.status().ok" | mongo --quiet) -eq 1
      interval: 10s
      start_period: 30s

volumes:
  mongo-data:

When running this as a dev-enviroment though I'm getting the error:

invalid interpolation format for services.mongodb.healthcheck.test.[]: "test $(echo \"rs.initiate().ok || rs.status().ok\" | mongo --quiet) -eq 1". You may need to escape any $ with another $
exit status 15

It already has two $. I've tried adding another and removing one.

To Reproduce Steps to reproduce the behavior:

  1. Create a docker compose project using the docker-compose.yaml file above
  2. In Docker Desktop application, create a Dev environment using the local project
  3. During setup it will error with exist status 15

Expected behavior It is already escaped and should run as if "docker-compose up" was called

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Version of Docker Desktop:
You can find the version by clicking on the About Docker Desktop menu

Docker Desktop 4.9.0 (80466)

Additional context Add any other context about the problem here.

joezappie commented 2 years ago

Thinking about this, I'm guessing that it has something to do with the generated devenv-docker-compose.yaml that shows up. I changed my stuff to use an bash script in a separate container so unfortunately I can't check that yaml file to see if its for some removing a $. I vaguely remember seeing this when testing the other day though but it didn't register to me that was happening.