Running Docker for Windows, Error when exposing Ports

后端 未结 10 1517
天命终不由人
天命终不由人 2021-01-31 01:10

I am aware there are a lot of questions about running Docker on windows, however this question is about running the brand new Docker for Windows, on Windows.
In my case I am

相关标签:
10条回答
  • 2021-01-31 01:54

    If its in windows OS, Please do restart the Docker This has fixed the issue for me

    0 讨论(0)
  • 2021-01-31 01:55

    I got the same issue before on window 10. Restart docker, it works

    0 讨论(0)
  • 2021-01-31 01:59

    If you are here because you have this issue in Visual Studio 2019:

    According to this post, the VS team is preparing a fix for this issue in 16.5 version, meanwhile, you can add the property "publishAllPorts": true in your launchSettings.json, for example:

    "Docker": {
          "commandName": "Docker",
          "launchBrowser": true,
          "launchUrl": "{Scheme}://{ServiceHost}:44374", #<== Set a fixed port
          "environmentVariables": {
            "ASPNETCORE_URLS": "https://+:44374;https://+:5000",
            "ASPNETCORE_HTTPS_PORT": "44374"
          },
          "publishAllPorts": true, #<== This is equivalent to the -P flag in 'docker run'
          "useSSL": true
        }
    

    Notice that the property "httpPort": XYZT is not defined. Having it defined will make the workaround not work.

    It worked for me with this setup:

    • Windows 10 1709 Build 16299.1747 with Fast Start OFF
    • Docker Desktop 2.2.05 (43884)
    • Docker Engine 19.03.8
    • Visual Studio 2019 Enterprise 16.5.4.
    • Microsoft.VisualStudio.Azure.Containers.Tools.Targets 1.10.8

    I realized that the command VS was creating, contained the -p parameter twice, one with the port I specified and another with port 80, like this: -p 3010:80 -p 3010:3010.

    After adding publishAllPorts it now creates the container and I can remotely debug it.

    0 讨论(0)
  • 2021-01-31 02:03

    1) Stop all the running containers docker stop $(docker ps -a -q) then

    2) Stop the Docker on your machine & restart it.

    Then run the required command. This will solve the issue.

    0 讨论(0)
  • 2021-01-31 02:03

    For Linux - Debian Users,

    Use docker stop $(docker ps -a -q) only when you know whether you want to stop all the containers or not.... If yes then please run docker rm $(docker ps -a -q) to remove containers ....

    Then stop the docker daemon - systemctl stop docker Then start docker daemon - systemctl start docker

    Also verify whether docker daemon is up or not - service docker status

    After following all above mention steps you should be fine.....

    0 讨论(0)
  • 2021-01-31 02:04

    Try stopping docker and initiating it again on administrator mode. After it starts open power shell on administrator mode as well. Because the error says "mkdir" maybe this will solve your problem. Im not sure but it worked for me. In the case of using -P a port conflict does not seen to be the reason for the error once -P will chose ports randomly. The error it self wasn't quite friendly to me but because I saw the mkdir word on it I imagined it might be a permission error, thats why I restarted docker on administrator mode and started power shell on administrator mode.

    0 讨论(0)
提交回复
热议问题