无法连接到由docker compose启动的.net容器

时间:2019-03-13 06:45:40

标签: .net docker docker-compose

我使用mysql数据库启动了.net服务,并且所有容器都在运行

109eeaf260e8        authentication_service:latest   "dotnet out/Authenti…"   9 seconds ago       Up 7 seconds        0.0.0.0:5003->80/tcp     authenticationservice_authentication_service_1
5da4ab86b093        mysql:8.0.3                     "docker-entrypoint.s…"   10 seconds ago      Up 8 seconds        0.0.0.0:3305->3306/tcp   authenticationservice_authentication_service_d

现在,我也通过邮递员向http://192.168.0.4:5003/api/authentication/5:5000:80尝试过的authentification_serivce:PORT发送HTTP请求。但总是会收到超时或找不到。

当我通过IDE启动相同文件并调用http://localhost:5000/api/authentication/5时,我会收到期望的值。

我尝试在EXPOSE 80中使用Dockerfile,但是没有成功。

我的docker-compose:

version: '3.1'

networks:
  overlay:
services:
  authentication_service:
    image: authentication_service:latest
    depends_on:
      - "authentication_service_db"
      - "adminer"
    build:
      context: .
      dockerfile: Dockerfile
    links:
      - authentication_service_db
    ports:
      - 5003:80
    networks:
      - overlay
  authentication_service_db:
    image: mysql:8.0.3
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: authenticationdb
    ports:
      - 3305:3306
    restart: always
    volumes:
      - ./data-authentication:/var/lib/mysql
    networks:
      - overlay
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    networks:
      - overlay

我的容器正在生活(并在听)

Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

所以我很困惑。如何连接到服务中的.net应用程序?看来我的端口映射错误,或者我忘记了在docker-compose或.net中的基本配置?

(如果您需要项目或Dockerfile中的更多配置,请发表评论)

0 个答案:

没有答案