简体   繁体   English

Docker与MongoDB(和Microsoft Azure)组成

[英]Docker compose with MongoDB (and Microsoft Azure)

I'm trying to launch an app on Microsoft Azure using docker-compose file. 我正在尝试使用docker-compose文件在Microsoft Azure上启动应用程序。 This is the error I'm getting in the logs 这是我在日志中遇到的错误

2019-06-18T18:12:55.319003252Z Successfully added user: {
2019-06-18T18:12:55.361353763Z     "user" : "myuser1",
2019-06-18T18:12:55.361371063Z     "roles" : [
2019-06-18T18:12:55.361387163Z         {
2019-06-18T18:12:55.361392063Z             "role" : "root",
2019-06-18T18:12:55.361396763Z             "db" : "admin"
2019-06-18T18:12:55.361401363Z         }
2019-06-18T18:12:55.361405563Z     ]
2019-06-18T18:12:55.361409964Z }
2019-06-18T18:12:55.367946981Z 2019-06-18T18:12:55.331+0000 E -        [main] Error saving history file: FileOpenFailed: Unable to open() file /home/mongodb/.dbshell: Unknown error
2019-06-18T18:12:55.399399764Z 
2019-06-18T18:12:55.399413964Z 2019-06-18T18:12:55.389+0000 I NETWORK  [conn2] end connection 127.0.0.1:50370 (0 connections now open)
2019-06-18T18:12:55.465992339Z /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2019-06-18T18:12:55.466010339Z 
2019-06-18T18:12:58.011530247Z 2019-06-18T18:12:58.011+0000 I CONTROL  [main] ***** SERVER RESTARTED *****

This is how my part for mongoDB looks like in docker-compose.yml : 这就是我的mongoDB部分在docker docker-compose.yml

version: '3'
services:
  ...other services
  mongo:
    image: mongo:latest
    container_name: my-mongo
    restart: unless-stopped
    volumes:
      - my-mongo:/data/db
    environment:
      - MONGO_INITDB_ROOT_USERNAME=myusername
      - MONGO_INITDB_ROOT_PASSWORD=mysupersecretpassword
    ports:
      - 27017:27017
    networks:
      - myservices-net

The whole docker-compose file works locally on my machine, but it does not want to work on Microsoft Azure. 整个docker-compose文件在我的计算机上本地工作,但是它不希望在Microsoft Azure上工作。

I've found this issue on GitHub but I'm not really sure how to apply the changes to my docker-compose file. 我在GitHub上发现了这个问题,但是我不确定如何将更改应用到我的docker-compose文件中。 Would really appreciate any help here! 非常感谢您的帮助!

For your issue, the possible reason would be that the networks property is not supported in the compose file in Azure Web App. 对于您的问题,可能的原因是Azure Web App的撰写文件中不支持networks属性。 You can see all the Compose options supported and unsupported. 您可以看到所有支持和不支持的撰写选项。

Supported options 支持的选项

  • command 命令
  • entrypoint 入口点
  • environment 环境
  • image 图片
  • ports 港口
  • restart 重新开始
  • services 服务
  • volumes

Unsupported options 不支持的选项

  • build (not allowed) 构建(不允许)
  • depends_on (ignored) Depends_on(忽略)
  • networks (ignored) 网络(忽略)
  • secrets (ignored) 机密(忽略)
  • ports other than 80 and 8080 (ignored) 80和8080以外的端口(忽略)

For more details, see Docker Compose options . 有关更多详细信息,请参阅Docker Compose options

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM