Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 服务不';不要在Docker中进行内部通信_Asp.net_Docker_Redis - Fatal编程技术网

Asp.net 服务不';不要在Docker中进行内部通信

Asp.net 服务不';不要在Docker中进行内部通信,asp.net,docker,redis,Asp.net,Docker,Redis,我试图在Docker上运行ASP.NET Core 2.0应用程序(REDIS+RabbitMQ+NGINX) 当我通过docker compose上传这些容器时,这些服务可以工作,甚至可以通过Windows访问,因为它们由“HostPORT:ContainerPORT”映射 然而,当测试应用程序本身时,.NET会在控制台中通知,例如,无法连接到REDIS fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HLDGDJ

我试图在Docker上运行ASP.NET Core 2.0应用程序(
REDIS
+
RabbitMQ
+
NGINX

当我通过
docker compose
上传这些容器时,这些服务可以工作,甚至可以通过Windows访问,因为它们由“HostPORT:ContainerPORT”映射

然而,当测试应用程序本身时,.NET会在控制台中通知,例如,无法连接到REDIS

fail: Microsoft.AspNetCore.Server.Kestrel[13]
  Connection id "0HLDGDJNAEB9E", Request id "0HLDGDJNAEB9E:00000001": An unhandled exception was thrown by the application.
  StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING.
My docker-compose.yml:

version: '3'

services:
  nginx:
    build:
      dockerfile: ./nginx/nginx.dockerfile
      context: .
    image: nginx
    container_name: nginx
    ports:
      - "80:80"
    networks:
      - production-network
    depends_on:
      - "wordSearcherApp"

  wordSearcherApp:
    image: wordsearcherapplication
    container_name: wordsearcherapp
    build:
      context: .
      dockerfile: WordSearcher/Dockerfile
    networks:
      - production-network
    ports:
      - "61370"
    volumes:
      - repository:/repository
    depends_on:
      - redis
      - rabbit

  redis:
    image: redis
    container_name: redis
    ports:
      - "6379:6379"
    networks:
      - production-network

  rabbit:
    image: rabbitmq
    container_name: rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    networks:
      - production-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:15672"]
      interval: 30s
      timeout: 10s
      retries: 5

networks:
  production-network:
    driver: bridge

volumes:
  repository:
    driver: local
对于C#中的连接,我使用这个connectionString
localhost:6379

我该怎么做?
谢谢。

使用
redis:6379
而不是
localhost:6379

Docker Compose将使用您在Docker-Compose.yml文件中为服务定义的名称作为其容器的主机名