Docker ip for windows

I am testing Docker with a basic .NET base project. I create and draw from this docker file:

FROM microsoft/dotnet:latest

COPY . /app

WORKDIR /app/API

RUN ["dotnet", "restore"]

RUN ["dotnet", "build"]

EXPOSE 5000/tcp

CMD ["dotnet", "run", "--server.urls", "http://*:5000"]

I run it and it goes flawlessly. Now the only problem is which IP server is it running on?

I am running Docker on Windows!

Hi

+8
source share
3 answers

You are already opening the port inside, so the only thing I can offer is to check that you open the port when you start your image:

docker run -it -p 5000:5000 <imagename>

This will open port 5000 inside the instance on port 5000 on your local computer and then be available on 127.0.0.1:5000or localhost:5000.

, Main() Program.cs .UseUrls("http://*:5000/") WebHostBuilder.

+7

Linux-, dotnet asp.net core 2 Docker Windows.

, , :

docker run -it --rm -p 3394:3394 --name <name> <container>

, .

3394 127.0.0.1, localhost ip NAT .

IP-, :

docker inspect -f "{{ .NetworkSettings.IPAddress }}" <name>

IP 172.17.0.2. 172.17.0.2:3394 .

:

route /P add 172.0.0.0 MASK 255.0.0.0 10.0.75.2

, , tracert.

https://github.com/docker/for-win/issues/221

+8

I managed to connect to the open port of the container through the IP address of the dock machine:

docker-machine ip

In my case it was 192.168.99.100

So for my MySQL container ( docker run -d -p 3306:33060 -e MYSQL_ROOT_PASSWORD=password mysql:5.7) so that I was able to connect through192.168.99.100:33060

0
source

Source: https://habr.com/ru/post/1667083/


All Articles