Docker Community Forums

Share and learn in the Docker community.

How to make TCP client working in windows docker?

swarm

(Janebai) #1

I run a service inside of container, which connects to a third-party application on host through TCP connections. The service is TCP Client.

The third-party applications starts and listens to TCP connection on port number 3008. Then I start the container through the following command on powershell:
docker run -d -e TesterCmdLine="/port:3009 /server:localhost" -p 3008:3009 tcptester
The environment variable TesterCmdLine tells the service the TCP Server is localhost and the port number is 3009. The container port number 3009 should be published to host port number 3008.

But the container could start. The following error is printed:

PS C:\DockerTestWithTcp> docker run -d -e TesterCmdLine="/port:3009 /server:localhost" -p 3008:3009 tcptester
4e4b7d689bfe504fbbc867317eb57317a1eff1ab866e871711af91b995812092
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: failed to create endpoint naughty_turing on network nat: HNS failed with error : The process cannot access the file because it is being used by another process.

If I run the service as TCP Server in the container, it works fine.

Any idea why the TCP Client doesn’t work in container with published port?

Thanks a lot!