Kasra
Kasra

Reputation: 149

Connection reset by peer when when trying to access to Docker container

I know it might be a repetitive question but I already have tried them almost all with no success!

The problem is I can successfully communicate with 2 out of 3 images but all connection will be reset from rotbeh.net.api

I exec into the container and execute curl localhost:5000 successfully but from outside nothing will happen

My API is written by C# net core 3.1 and Here is my docker-compose file :

version: '3.8'

services:
  sqlserver:
    container_name: sqlserver
    image: mssql2019fts
    restart: always
    volumes:
      - '/var/opt/mssql/data:/var/opt/mssql/data'
    environment:
      - ACCEPT_EULA='Y'
      - SA_PASSWORD=******
      - FullText=true
    ports:
      - '1433:1433'

  rotbeh.net.api:
    container_name: rotbeh.net.api
    image: rotbeh.net.api
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
    restart: always
    ports:
      - '5000:5000'
    depends_on:
      - sqlserver

  rotbeh.net-ui:
    container_name: rotbeh.net-ui
    image: rotbeh.net-ui
    restart: always
    ports:
      - '3000:3000'
    depends_on:
      - rotbeh.net.api

Upvotes: 3

Views: 4102

Answers (1)

maxm
maxm

Reputation: 3667

You need to listen on '0.0.0.0' within the container. Your listener values should be something like:

{
   "Host":{
      "BaseUrl":"0.0.0.0",
      "Port":5000
   },
   "Kestrel":{
      "Endpoints":{
         "HttpsDefaultCert":{
            "Url":"0.0.0.0:5000",
            "Protocols":"Http1"
         }
      }
   }
}

Upvotes: 6

Related Questions