简体   繁体   中英

Unable to connect to a docker container microservice

I am running a microservice inside a docker container using docker compose. The docker-compose.yml file is as follows.

version: '2.1'
services:
flousermanagement:
  build: 
    context: ../FloUserManagement/bin/Debug/netcoreapp2.0/publish
    dockerfile: Dockerfile
  ports:
   - "5001:5001"
   - "8080:8080"
  volumes:
   - 

      ../FloUserManagement/bin/Debug/netcoreapp2.0/publish/data: 
      c:\floUserManagement\data   

The dockerfile.

 FROM microsoft/dotnet:2.0.0-preview2-sdk-nanoserver
 ENTRYPOINT ["dotnet", "FloUserManagement.dll"]
 ARG source=.
 WORKDIR /floUserManagement
 ENV ASPNETCORE_URLS http://+:5001
 EXPOSE 5001
 EXPOSE 8080
 COPY $source .

I am unable to connect to locahost. The code running without the container works just fine but not within the container. I tried tracking the requests on the container but I am not able to hit any endpoints inside the container on locahost:5000.

Is it due to the dotnet core 2.0.0-preview2 version upgrade? Is it due to localhost not getting mapped in IPv6 from IPv4? What could be the workaround for this?

I am running docker enterprise edition on azure vm. Windows Server 2016 datacenter Intel Xeon 2.4GHz Dual Core. x64 bit 7GB RAM. I am using Docker enterprise and not the community edition.

It's a bug in current implementation of WinNAT. Connection to localhost published port is not going to work from the same host. You will be able to use mapped port from outside container but not locally. This is not seems to be scheduled to be fixed untill next major release of Windows 2016. ( https://docs.docker.com/docker-for-windows/troubleshoot/#limitations-of-windows-containers-for-localhost-and-published-ports )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM