docker - 在 192.168.65.5 上查找 :53: no such host

标签 docker nginx

我尝试在 docker 中运行 nginx,并将其连接到 docker 中的一项服务。另一个服务在没有 docker 的情况下运行,也使用这个 nginx。我的 docker-compose:

version: "3.9"

services:
  nginx:
    restart: always
    image: nginx
    volumes:
      - ./config/nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - "3000:80"
      - "9000:81"

  web:
    restart: always
    image: "xxxx/xxxx/web"

nginx conf 位于 ./config/nginx.conf:

events {}

http{
    upstream ws-api {
        server host.docker.internal:8081;
    }

    upstream ws-web {
        server web;
    }



    server {
        server_name localhost;
        listen      80;
     
        location / {
            include fastcgi_params;
            fastcgi_split_path_info ^(/)(.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_pass  ws-api;
        }
    }

    server {
        server_name localhost;
        listen      81;
     
        location / {
            include fastcgi_params;
            proxy_pass http://ws-web;
        }

        location /api {
            rewrite        ^([^.]*[^/])$ $1/;
            rewrite        ^/api(.*)$ $1 break;

            include fastcgi_params;
            fastcgi_split_path_info ^(/)(.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_pass  ws-api;
        }
    }
}

当我打开 localhost:9000 时,我收到错误消息:

lookup ws-web on 192.168.65.5:53: no such host

localhost:3000 工作正常

我的错误是什么?

最佳答案

将 Docker 更新到最新的 Apple Silicon Preview 版本为我解决了这个问题。

Here

关于docker - 在 192.168.65.5 上查找 :53: no such host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66804528/

相关文章:

docker - 将多个 docker 容器部署到 AWS ECS

docker - 某些容器的 Traefik > "Bad gateway"(错误 502)

docker - 实例化Chaincode时Chaincode for Developers教程错误

php - Nginx 重写 PHP 文件获取下载

django - 在真实服务器中部署 django-channels 的最佳方式

python - Docker 应用程序找不到名为 'graphene_django' 的模块

Docker 套接字在堆栈后崩溃

javascript - 无法在 Express.JS 中使用 nginx 的路由

ruby-on-rails - nginx url 从 www 重定向到 https 的无 www

nginx autoindex 仅适用于内部 IP 地址