0

I have a mongodb service and a test service running with docker-compose:

services:   
  mongo:
    image: myrepo/mongo
    ports:
      - "27017:27017"
  test:
    depends_on:
      - mongo
    image: myrepo/elixir-tests
    command: sh start.sh

in the start.sh script i am trying to run:

mongo 172.20.0.10:27017/wc-app-sandbox --eval "printjson(....))"

but i get the following error :

start.sh: 10: start.sh: mongo: not found 

My question is: why does the error happen- doesn't the depends_on property suppose to automatically include service dependencies? as mention here:

depends_on

Express dependency between services, which has two effects:

docker-compose up will start services in dependency order. In the following example, db and redis will be started before web. docker-compose up SERVICE will automatically include SERVICE’s dependencies. In the following example, docker-compose up web will also create and start db and redis.

Community
  • 1
  • 1
fay
  • 2,086
  • 2
  • 14
  • 36

1 Answers1

1

This error does't mean "i can't find route to mongo container", it means "i dont found mongo execution bin. Probably image myrepo/elixir-tests does't contain mongo-client. Try to install it apt update && apt install mongodb-clients into your container.

and mongo connection string should be looks like mongo mongo:27017/wc-app-sandbox --eval "printjson(....))"

Bukharov Sergey
  • 9,767
  • 5
  • 39
  • 54