这是我的 docker-compose.yml 文件

version: '3.1'

services:

  mongo:
    image: mongo
    restart: always
    container_name: mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  mongo-express:
    image: mongo-express
    restart: always
    depends_on:
      - mongo
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example

当我运行$ sudo docker-compose up 时,我得到以下信息......

mongo-express_1  | Waiting for mongo:27017...
mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
mongo            | {"t":{"$date":"2020-11-11T19:30:18.053+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.055+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.056+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"84a58d09b1ca"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1  11 Sep 2018","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"18.04"}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"*"},"security":{"authorization":"enabled"}}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.087+00:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/data/db","storageEngine":"wiredTiger"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.087+00:00"},"s":"I",  "c":"STORAGE",  "id":22297,   "ctx":"initandlisten","msg":"Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem","tags":["startupWarnings"]}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.088+00:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=256M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.726+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123018:726666][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 4 through 5"}}
mongo-express_1  | Wed Nov 11 19:30:18 UTC 2020 retrying to connect to mongo:27017 (2/5)
mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
mongo            | {"t":{"$date":"2020-11-11T19:30:18.800+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123018:800799][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 5 through 5"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.003+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:3557][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Main recovery loop: starting at 4/6528 to 5/256"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.129+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:129560][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 4 through 5"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.220+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:220139][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 5 through 5"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.279+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:279027][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Set global recovery timestamp: (0, 0)"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.279+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:279109][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Set global oldest timestamp: (0, 0)"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.316+00:00"},"s":"I",  "c":"STORAGE",  "id":4795906, "ctx":"initandlisten","msg":"WiredTiger opened","attr":{"durationMillis":1228}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.316+00:00"},"s":"I",  "c":"RECOVERY", "id":23987,   "ctx":"initandlisten","msg":"WiredTiger recoveryTimestamp","attr":{"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.417+00:00"},"s":"I",  "c":"STORAGE",  "id":22262,   "ctx":"initandlisten","msg":"Timestamp monitor starting"}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.607+00:00"},"s":"I",  "c":"STORAGE",  "id":20536,   "ctx":"initandlisten","msg":"Flow Control is enabled on this deployment"}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.648+00:00"},"s":"I",  "c":"FTDC",     "id":20625,   "ctx":"initandlisten","msg":"Initializing full-time diagnostic data capture","attr":{"dataDirectory":"/data/db/diagnostic.data"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.651+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"/tmp/mongodb-27017.sock"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.651+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"0.0.0.0"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.651+00:00"},"s":"I",  "c":"NETWORK",  "id":23016,   "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
mongo-express_1  | Wed Nov 11 19:30:19 UTC 2020 retrying to connect to mongo:27017 (3/5)
mongo            | {"t":{"$date":"2020-11-11T19:30:19.740+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.28.0.3:46578","connectionId":1,"connectionCount":1}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.741+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn1","msg":"Connection ended","attr":{"remote":"172.28.0.3:46578","connectionId":1,"connectionCount":0}}
mongo-express_1  | Welcome to mongo-express
mongo-express_1  | ------------------------
mongo-express_1  | 
mongo-express_1  | 
mongo-express_1  | Mongo Express server listening at http://0.0.0.0:8081
mongo-express_1  | Server is open to allow connections from anyone (0.0.0.0)
mongo-express_1  | basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
mongo            | {"t":{"$date":"2020-11-11T19:30:20.565+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.28.0.3:46580","connectionId":2,"connectionCount":1}}
mongo            | {"t":{"$date":"2020-11-11T19:30:20.586+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn2","msg":"client metadata","attr":{"remote":"172.28.0.3:46580","client":"conn2","doc":{"driver":{"name":"nodejs","version":"2.2.24"},"os":{"type":"Linux","name":"linux","architecture":"x64","version":"5.4.0-1028-gcp"},"platform":"Node.js v12.19.0, LE, mongodb-core: 2.1.8"}}}
mongo-express_1  | Database connected
mongo            | {"t":{"$date":"2020-11-11T19:30:20.936+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn2","msg":"Successful authentication","attr":{"mechanism":"SCRAM-SHA-1","principalName":"root","authenticationDatabase":"admin","client":"172.28.0.3:46580"}}
mongo-express_1  | Admin Database connected
mongo            | {"t":{"$date":"2020-11-11T19:30:20.944+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.28.0.3:46582","connectionId":3,"connectionCount":2}}
mongo            | {"t":{"$date":"2020-11-11T19:30:21.028+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn3","msg":"Successful authentication","attr":{"mechanism":"SCRAM-SHA-1","principalName":"root","authenticationDatabase":"admin","client":"172.28.0.3:46582"}}

我尝试手动创建网络,公开端口,更改名称,将端口绑定到主机,更改端口等......这个例子最有趣的事情来自https://hub.docker.com/_/mongo 我唯一添加的是

    depends_on:
      - mongo

我还尝试为 mongo-express ME_CONFIG_MONGODB_SERVER=mongo 添加环境变量,但它是默认的,所以没有用;(

有什么建议么?

#1楼 票数:1

这是我的 docker-compose.yml 文件

version: '3.1'

services:

  mongo:
    image: mongo
    restart: always
    container_name: mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  mongo-express:
    image: mongo-express
    restart: always
    depends_on:
      - mongo
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example

当我运行$ sudo docker-compose up 时,我得到以下信息......

mongo-express_1  | Waiting for mongo:27017...
mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
mongo            | {"t":{"$date":"2020-11-11T19:30:18.053+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.055+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.056+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"84a58d09b1ca"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1  11 Sep 2018","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"18.04"}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.057+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"*"},"security":{"authorization":"enabled"}}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.087+00:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/data/db","storageEngine":"wiredTiger"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.087+00:00"},"s":"I",  "c":"STORAGE",  "id":22297,   "ctx":"initandlisten","msg":"Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem","tags":["startupWarnings"]}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.088+00:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=256M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:18.726+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123018:726666][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 4 through 5"}}
mongo-express_1  | Wed Nov 11 19:30:18 UTC 2020 retrying to connect to mongo:27017 (2/5)
mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
mongo            | {"t":{"$date":"2020-11-11T19:30:18.800+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123018:800799][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 5 through 5"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.003+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:3557][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Main recovery loop: starting at 4/6528 to 5/256"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.129+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:129560][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 4 through 5"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.220+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:220139][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 5 through 5"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.279+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:279027][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Set global recovery timestamp: (0, 0)"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.279+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1605123019:279109][1:0x7f5a73e15a80], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Set global oldest timestamp: (0, 0)"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.316+00:00"},"s":"I",  "c":"STORAGE",  "id":4795906, "ctx":"initandlisten","msg":"WiredTiger opened","attr":{"durationMillis":1228}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.316+00:00"},"s":"I",  "c":"RECOVERY", "id":23987,   "ctx":"initandlisten","msg":"WiredTiger recoveryTimestamp","attr":{"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.417+00:00"},"s":"I",  "c":"STORAGE",  "id":22262,   "ctx":"initandlisten","msg":"Timestamp monitor starting"}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.607+00:00"},"s":"I",  "c":"STORAGE",  "id":20536,   "ctx":"initandlisten","msg":"Flow Control is enabled on this deployment"}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.648+00:00"},"s":"I",  "c":"FTDC",     "id":20625,   "ctx":"initandlisten","msg":"Initializing full-time diagnostic data capture","attr":{"dataDirectory":"/data/db/diagnostic.data"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.651+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"/tmp/mongodb-27017.sock"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.651+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"0.0.0.0"}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.651+00:00"},"s":"I",  "c":"NETWORK",  "id":23016,   "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
mongo-express_1  | Wed Nov 11 19:30:19 UTC 2020 retrying to connect to mongo:27017 (3/5)
mongo            | {"t":{"$date":"2020-11-11T19:30:19.740+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.28.0.3:46578","connectionId":1,"connectionCount":1}}
mongo            | {"t":{"$date":"2020-11-11T19:30:19.741+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn1","msg":"Connection ended","attr":{"remote":"172.28.0.3:46578","connectionId":1,"connectionCount":0}}
mongo-express_1  | Welcome to mongo-express
mongo-express_1  | ------------------------
mongo-express_1  | 
mongo-express_1  | 
mongo-express_1  | Mongo Express server listening at http://0.0.0.0:8081
mongo-express_1  | Server is open to allow connections from anyone (0.0.0.0)
mongo-express_1  | basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
mongo            | {"t":{"$date":"2020-11-11T19:30:20.565+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.28.0.3:46580","connectionId":2,"connectionCount":1}}
mongo            | {"t":{"$date":"2020-11-11T19:30:20.586+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn2","msg":"client metadata","attr":{"remote":"172.28.0.3:46580","client":"conn2","doc":{"driver":{"name":"nodejs","version":"2.2.24"},"os":{"type":"Linux","name":"linux","architecture":"x64","version":"5.4.0-1028-gcp"},"platform":"Node.js v12.19.0, LE, mongodb-core: 2.1.8"}}}
mongo-express_1  | Database connected
mongo            | {"t":{"$date":"2020-11-11T19:30:20.936+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn2","msg":"Successful authentication","attr":{"mechanism":"SCRAM-SHA-1","principalName":"root","authenticationDatabase":"admin","client":"172.28.0.3:46580"}}
mongo-express_1  | Admin Database connected
mongo            | {"t":{"$date":"2020-11-11T19:30:20.944+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.28.0.3:46582","connectionId":3,"connectionCount":2}}
mongo            | {"t":{"$date":"2020-11-11T19:30:21.028+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn3","msg":"Successful authentication","attr":{"mechanism":"SCRAM-SHA-1","principalName":"root","authenticationDatabase":"admin","client":"172.28.0.3:46582"}}

我尝试手动创建网络,公开端口,更改名称,将端口绑定到主机,更改端口等......这个例子最有趣的事情来自https://hub.docker.com/_/mongo 我唯一添加的是

    depends_on:
      - mongo

我还尝试为 mongo-express ME_CONFIG_MONGODB_SERVER=mongo 添加环境变量,但它是默认的,所以没有用;(

有什么建议么?

  ask by Maksym Antoshkin translate from so

未解决问题?本站智能推荐:

1回复

在docker中连接mongo express服务的问题

我有一个 docker 配置,我在其中启动了 nginx 服务器。 现在我必须运行 mongo 和 mongo-express 才能连接到我的数据库。 当我将这两个配置放入 docker-compose.yml 并尝试 docker compose up 时,mongo 服务启动但 mongo ex
3回复

由 Docker-Compose 启动的 Mongo-Express 导致错误 [MongoError]:首次连接时无法连接到服务器 [mongo:27017]

场景:我想从同一个 docker-compose 启动 Mongo 和 Mongo-Express。 我只从 docker-compose 启动 mongodb 没有问题。 当我尝试将 Mongo-Express 链接到 Mongo DB 服务时,问题就出现了。 我不确定我是否缺少 docker
3回复

官方 Mongo Docker Image 页面上提供的 YAML 在 CentOS 上不起作用

下面的 YAML 文件(最初在此处提供)适用于 Windows 和 macOS docker 环境。 但是当我在 CentOS 环境中运行它时, mongo-express无法连接到 MongoDB 服务并且它没有显示在localhost:8081的浏览器中。 我想这是 DNS 和将 Mongo 映
1回复

使用 docker compose 在不同的服务中使用/引用容器名称

我docker-compose.yml文件如下所示: 要使mongo-express工作,我需要能够将db / mongo容器名称传递给它。 有没有办法通过 compose 实现这一点?
1回复

如何在 mongodb 的 docker-compose 文件中附加持久卷?

我有一个 docker-compose 文件,它将在同一网络“mynet”中启动 mongo 和 mongo-express 容器。 我通过以下方式创建了一个网络: 我通过 docker 命令在外部创建了一个名为“demo-vol”的卷。 在容器内,我创建了一个示例 mongo 集合。 当我
1回复

MongoExpress 不从 .env 文件读取登录名/密码

我正在使用 docker-compose 将环境变量设置为: 环境: 只有当我这样做时: 它在那里工作,但我想这样做,以便您可以轻松编辑凭据。 出于某种原因,当我为 mongoDB 执行环境变量时,它可以工作: 这是我的 env 文件
1回复

Mongo Express 服务器监听 http://0.0.0.0:8081

我已经像上面一样编码了我的 docker-compose.yaml 文件。 两者都在之后运行。 但是,mongo-express 出现了 403 禁止错误。 当我检查 Visual Studio 代码中的视图日志时。 我看到这个错误:
1回复

尝试连接 MongoDB Kubernetes 集群时 mongo-express 的身份验证问题(使用 MongoDB Community Kubernetes Operator 创建)

我与 MongoDB Community Kubernetes Operator 建立了一个 Minikube-Cluster。 要查看内容,我想设置一个连接到 Mongo-Cluster/ReplicaSet 的 mongo-express 实例。 但是如果我应用部署容器总是失败: 为了便于测