I’m trying a very basic setup as per the docker compose tutorial, and it fails with this error:
Drippy-Inc+drippy-app-backend git:develop ❯ docker compose up mongoshell
[+] Running 3/3
✔ Network drippy-incdrippy-app-backend_default Created 0.0s
✔ Container drippy-incdrippy-app-backend-mongodb-1 Created 0.2s
✔ Container drippy-incdrippy-app-backend-mongoshell-1 Created 0.2s
Attaching to mongoshell-1
mongoshell-1 | MongoNetworkError: getaddrinfo ENOTFOUND mongodb
mongoshell-1 | Traceback (most recent call last):
mongoshell-1 | File "/usr/local/bin/docker-entrypoint.py", line 644, in <module>
mongoshell-1 | subprocess.run(get_command_line_args(), check=True)
mongoshell-1 | File "/usr/lib64/python3.9/subprocess.py", line 528, in run
mongoshell-1 | raise CalledProcessError(retcode, process.args,
mongoshell-1 | subprocess.CalledProcessError: Command '['/bin/bash', '-c', 'sleep 5; mongosh $CONN_STR --eval "show dbs;"']' returned non-zero exit status 1.
mongoshell-1 exited with code 1
The docker-compose.yml file:
services:
mongoshell:
image: mongodb/mongodb-community-server:7.0.11-ubi8
environment:
- CONN_STR=mongodb://user:pass@mongodb
command: '/bin/bash -c "sleep 5; mongosh $$CONN_STR --eval \"show dbs;\""'
depends_on:
- mongodb
mongodb:
image: mongodb/mongodb-community-server:7.0.11-ubi8
environment:
- MONGO_INITDB_ROOT_USERNAME=user
- MONGO_INITDB_ROOT_PASSWORD=pass
volumes:
- type: bind
source: ./data
target: /data/db
The only differences are:
- my app name is “mongoshell” instead of “myapplication”
- and the mongo version is
7.0.11-ubi8
instead of6.0-ubi8
Why is it not working?