这是我的 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 添加环境变量,但它是默认的,所以没有用;(
有什么建议么?