{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/23086","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/23086/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/23086/comments","events_url":"https://api.github.com/repos/docker/docker/issues/23086/events","html_url":"https://github.com/docker/docker/issues/23086","id":157375259,"number":23086,"title":"Problem with Windows 10 nano container reusing port mapping: HNS failed with error : The object already exists..","user":{"login":"StefanScherer","id":207759,"avatar_url":"https://avatars.githubusercontent.com/u/207759?v=3","gravatar_id":"","url":"https://api.github.com/users/StefanScherer","html_url":"https://github.com/StefanScherer","followers_url":"https://api.github.com/users/StefanScherer/followers","following_url":"https://api.github.com/users/StefanScherer/following{/other_user}","gists_url":"https://api.github.com/users/StefanScherer/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanScherer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanScherer/subscriptions","organizations_url":"https://api.github.com/users/StefanScherer/orgs","repos_url":"https://api.github.com/users/StefanScherer/repos","events_url":"https://api.github.com/users/StefanScherer/events{/privacy}","received_events_url":"https://api.github.com/users/StefanScherer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/group/networking","name":"group/networking","color":"F6FBFF"},{"url":"https://api.github.com/repos/docker/docker/labels/group/windows","name":"group/windows","color":"F6FBFF"},{"url":"https://api.github.com/repos/docker/docker/labels/version/master","name":"version/master","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-29T08:20:39Z","updated_at":"2016-05-31T19:31:10Z","closed_at":null,"body":"**Output of `docker version`:**\r\n\r\n```\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker version\r\nClient:\r\n Version:      1.12.0-dev\r\n API version:  1.24\r\n Go version:   go1.5.3\r\n Git commit:   8e92415\r\n Built:        Thu May 26 17:08:34 2016\r\n OS/Arch:      windows/amd64\r\n\r\nServer:\r\n Version:      1.12.0-dev\r\n API version:  1.24\r\n Go version:   go1.5.3\r\n Git commit:   8e92415\r\n Built:        Thu May 26 17:08:34 2016\r\n OS/Arch:      windows/amd64\r\n```\r\n\r\n\r\n**Output of `docker info`:**\r\n\r\n```\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker info\r\nContainers: 3\r\n Running: 0\r\n Paused: 0\r\n Stopped: 3\r\nImages: 6\r\nServer Version: 1.12.0-dev\r\nStorage Driver: Windows filter storage driver\r\n Windows:\r\nLogging Driver: json-file\r\nPlugins:\r\n Volume: local\r\n Network: nat null\r\nKernel Version: 10.0 14352 (14352.1002.amd64fre.rs1_release.160522-1930)\r\nOperating System: Windows 10 Pro Insider Preview\r\nOSType: windows\r\nArchitecture: x86_64\r\nCPUs: 2\r\nTotal Memory: 2 GiB\r\nName: vagrant-10\r\nID: TLTO:YUSN:2MUU:HZTU:MRDE:ZYRA:2XWC:SP46:RCKW:HHMF:7UPJ:X7PU\r\nDocker Root Dir: C:\\ProgramData\\docker\r\nDebug Mode (client): false\r\nDebug Mode (server): false\r\nRegistry: https://index.docker.io/v1/\r\nInsecure Registries:\r\n 127.0.0.0/8\r\n```\r\n\r\n**Additional environment details (AWS, VirtualBox, physical, etc.):**\r\n\r\nVMware Fusion VM running Windows 10 Insider 14352 + Docker installed as described in the [Windows 10 Quick Start](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start_windows_10) guide\r\n\r\n**Steps to reproduce the issue:**\r\n1. Start a detached container with a port mapping, eg -p 3000:3000\r\n2. Kill the container\r\n3. Remove the container\r\n4. Build an updated container image (eg. after changing some code of your app)\r\n5. Start another detached container with the same port mapping, -p 3000:3000\r\n\r\n```\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker run -d --isolation=hyperv -p 3000:3000 hello\r\n4fd90ba44448d8760f2c5e6c21318f3731015d9155b434749ae45971901f2d5a\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker inspect 4f | sls IPAddress\r\n\r\n            \"SecondaryIPAddresses\": null,\r\n            \"IPAddress\": \"\",\r\n                    \"IPAddress\": \"172.22.46.160\",\r\n\r\n\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> start http://172.22.46.160:3000\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> notepad .\\app.js\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker kill 4f\r\n4f\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker rm -vf 4f\r\n4f\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker build --isolation=hyperv -t hello .\r\nSending build context to Docker daemon 9.728 kB\r\nStep 1 : FROM stefanscherer/node-windows:4.4-nano-onbuild\r\n# Executing 3 build triggers...\r\nStep 1 : COPY package.json package.json\r\n ---> Using cache\r\nStep 1 : RUN npm install\r\n ---> Using cache\r\nStep 1 : COPY . .\r\n ---> 617528d4f110\r\nRemoving intermediate container 09280c736a15\r\nSuccessfully built 617528d4f110\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker run -d --isolation=hyperv -p 3000:3000 hello\r\n```\r\n\r\n\r\n**Describe the results you received:**\r\n\r\nThe new container could not be started as the port mapping seems to still exist.\r\n\r\n```\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> docker run -d --isolation=hyperv -p 3000:3000 hello\r\n4f94d7f3a8b2e44dac87d36eb2fa7e2c1659b2a1b94ef74a689459b99b81ee2a\r\nC:\\Program Files\\Docker\\docker.exe: Error response from daemon: failed to create endpoint grave_volhard on network nat: HNS failed with error : The object already exists..\r\n```\r\n\r\n**Describe the results you expected:**\r\n\r\nThe new container should start with the specified port mapping.\r\n\r\n**Additional information you deem important (e.g. issue happens only occasionally):**\r\n\r\n```\r\nPS C:\\Users\\vagrant\\Desktop\\hello-node> get-netnat\r\n\r\n\r\nName                             : H27886532-6bc6-448a-9aab-548a9d87bba5\r\nExternalIPInterfaceAddressPrefix :\r\nInternalIPInterfaceAddressPrefix : 172.16.0.1/12\r\nIcmpQueryTimeout                 : 30\r\nTcpEstablishedConnectionTimeout  : 1800\r\nTcpTransientConnectionTimeout    : 120\r\nTcpFilteringBehavior             : AddressDependentFiltering\r\nUdpFilteringBehavior             : AddressDependentFiltering\r\nUdpIdleSessionTimeout            : 120\r\nUdpInboundRefresh                : False\r\nStore                            : Local\r\nActive                           : True\r\n\r\nPS C:\\WINDOWS\\system32> get-vmswitch\r\n\r\nName SwitchType NetAdapterInterfaceDescription\r\n---- ---------- ------------------------------\r\nnat  Internal\r\n```\r\n\r\nThe same issue occurs if you boot your Windows 10 / Windows 2016 TP5 machine and try to start a new container with the same host port mapping.\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/222795045","html_url":"https://github.com/docker/docker/issues/23086#issuecomment-222795045","issue_url":"https://api.github.com/repos/docker/docker/issues/23086","id":222795045,"user":{"login":"StefanScherer","id":207759,"avatar_url":"https://avatars.githubusercontent.com/u/207759?v=3","gravatar_id":"","url":"https://api.github.com/users/StefanScherer","html_url":"https://github.com/StefanScherer","followers_url":"https://api.github.com/users/StefanScherer/followers","following_url":"https://api.github.com/users/StefanScherer/following{/other_user}","gists_url":"https://api.github.com/users/StefanScherer/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanScherer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanScherer/subscriptions","organizations_url":"https://api.github.com/users/StefanScherer/orgs","repos_url":"https://api.github.com/users/StefanScherer/repos","events_url":"https://api.github.com/users/StefanScherer/events{/privacy}","received_events_url":"https://api.github.com/users/StefanScherer/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T19:31:10Z","updated_at":"2016-05-31T19:31:10Z","body":"@msabansal Indeed, running this in TP5 it works. Here is my walkthrough:\r\n\r\n```\r\ngit clone https://github.com/StefanScherer/dockerfiles-windows\r\ncd dockerfiles-windows\\node-hello-express\r\ndocker build -t hello-express -f Dockerfile.core .\r\ndocker run -d -p 3005:3000 --name=hello hello-express\r\ndocker kill hello\r\ndocker rm -vf hello\r\ndocker run -d -p 3005:3000 --name=hello hello-express\r\ndocker kill hello\r\ndocker rm -vf hello\r\n```\r\n\r\nKilling and removing the container works multipe times, reusing the same host port.\r\nBut then I tried restarting the host while the container is running:\r\n\r\n```\r\ndocker run -d -p 3005:3000 --name=hello hello-express\r\n```\r\n\r\nNow restart the host and login again\r\n\r\n```\r\ndocker ps -a\r\ndocker rm -vf hello\r\ndocker run -d -p 3005:3000 --name=hello hello-express\r\n34fb5d0aa760fc2b0261be7b2badd94c5129e78b18fd4620706181860d713017\r\nC:\\Windows\\system32\\docker.exe: Error response from daemon: failed to create endpoint hello on network nat: HNS failed with error : Failed to create endpoint.\r\n```\r\n\r\nIn that situation the port mapping seems to still exist.\r\n\r\n```\r\nGet-NetNatStaticMapping\r\n\r\n\r\nStaticMappingID               : 0\r\nNatName                       : Hff60d1c3-4269-4019-bb2a-51b643014677\r\nProtocol                      : TCP\r\nRemoteExternalIPAddressPrefix : 0.0.0.0/0\r\nExternalIPAddress             : 0.0.0.0\r\nExternalPort                  : 3000\r\nInternalIPAddress             : 172.18.113.186\r\nInternalPort                  : 3000\r\nInternalRoutingDomainId       : {00000000-0000-0000-0000-000000000000}\r\nActive                        : True\r\n\r\nStaticMappingID               : 7\r\nNatName                       : Hff60d1c3-4269-4019-bb2a-51b643014677\r\nProtocol                      : TCP\r\nRemoteExternalIPAddressPrefix : 0.0.0.0/0\r\nExternalIPAddress             : 0.0.0.0\r\nExternalPort                  : 3005\r\nInternalIPAddress             : 172.28.123.17\r\nInternalPort                  : 3000\r\nInternalRoutingDomainId       : {00000000-0000-0000-0000-000000000000}\r\nActive                        : True\r\n```\r\n\r\nOops, there's also another one."}}
{"actor":{"display_login":"StefanScherer"}}