从docker运行时连接到.netcore 1.1 web api中的mysql时出错

时间:2017-11-13 09:44:46

标签: mysql docker .net-core

我试图将dotnet core 1.1中的web api与MySQL作为后端进行对等。我为我的项目添加了docker支持。

dockerfile docker-compose.ci.build.yaml docker-compose.yml docker-compose。 override.yml 如下所示。但是我收到了像

这样的错误
  

MySql.Data.MySqlClient.MySqlException:' UnableToConnectToHost'   ExtendedSocketException:Connection refused ,,

dockerfile

FROM microsoft/aspnetcore:1.1
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "PDSController.dll"]

搬运工-compose.ci.build.yaml

version: '3'

services:
  ci-build:
    image: microsoft/aspnetcore-build:1.0-1.1
    volumes:
      - .:/src
    working_dir: /src
    command: /bin/bash -c "dotnet restore ./PDSController.sln && dotnet publish ./PDSController.sln -c Release -o ./obj/Docker/publish"

搬运工-compose.yml

version: '3'

services:
  pdscontroller:
    image: pdscontroller
    build:
      context: ./PDSController
      dockerfile: Dockerfile

搬运工-compose.override.yml

version: '3'

services:
  pdscontroller:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "80"

我必须在这些文件中进行哪些更改,以便在docker中运行时连接到我的数据库。我是码头工人的新手。请提前帮助,谢谢。此外,我计划将此api推送到AWS。

0 个答案:

没有答案