我创建了以nginx
运行的docker容器,并且确实有1个mongodb容器,一些laravel项目和1个nuxt-vue js项目。我的docker-compose.yml
文件如下所示:
version: '2'
services:
mongo:
image: mhoush/mongo
restart: always
ports:
- 27017:27017
environment:
MONGO_ROOT_USERNAME: root
MONGO_ROOT_PASSWORD: password
laravel-app1:
image: rifkyekayama/nginx-php-fpm-mongodb
restart: always
working_dir: /var/www/html
links:
- mongo
env_file: .env
environment:
VIRTUAL_HOST: laravel-app2.websitename.com
LETSENCRYPT_HOST: laravel-app2.websitename.com
GIT_REPO: 'git-path-api.git'
GIT_BRANCH: 'new-branch'
APP_LOCALE: id
DB_DATABASE: database
laravel-app2:
image: rifkyekayama/nginx-php-fpm-mongodb
restart: always
working_dir: /var/www/html
links:
- mongo
env_file: .env
environment:
VIRTUAL_HOST: laravel-app2.websitename.com
LETSENCRYPT_HOST: laravel-app2.websitename.com
GIT_REPO: 'git-path'
GIT_BRANCH: 'new-branch'
DB_DATABASE: database
frontend:
image: rifkyekayama/nginx-node-vue
restart: always
environment:
SSH_KEY: keys
VIRTUAL_HOST: nuxt-app.websitename.com
GIT_REPO: 'git-path'
GIT_BRANCH: 'new-branch'
YARN_INSTALL: 1
YARN_BUILD_COMMAND: 'yarn run build'
YARN_RUN_COMMAND: 'yarn run start'
NODE_PORT: 3005
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "/etc/nginx/certs"
我确定rifkyekayama/nginx-php-fpm-mongodb
软件包使用mongodb:/mongo:27017
调用mongo,但在laravel项目上仍然出现此错误
No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']
我该怎么办?谢谢