我正在尝试在docker上运行Express应用程序。应用程序取决于mongodb。我写了一个包含内容的撰写文件:
version: '3'
services:
mongo:
container_name: mongo
image: mongo
command: sh -c 'mongo'
network_mode: "host"
node:
container_name: test
# build: .
image: node
working_dir: /code
volumes:
- .:/code
ports:
- 3000:3000
depends_on:
- mongo
运行docker-compose后,出现以下错误:
mongo | MongoDB shell version v4.0.4
mongo | connecting to: mongodb://127.0.0.1:27017
mongo | WARNING: No implicit session: Logical Sessions are only supported on server versions 3.6 and greater.
mongo | Implicit session: dummy session
mongo | MongoDB server version: 3.2.22
mongo | WARNING: shell and server versions do not match
mongo | bye
请帮助我了解问题所在。
答案 0 :(得分:0)
请考虑将映像版本显式添加到mongo容器中,以确保您具有与客户端/ shell对应的版本。为此,在docker-compose文件中,将image: mongo
行替换为image: mongo:4.0
或与Shell版本4.0.4兼容的任何其他official Mongo version tag。