17

I'm trying to follow the beginner tutorial at training.play-with-docker.com. At Task 2, step 6, I do the following and get the error as below:

PS C:\Users\david.zemens\Source\Repos\linux_tweet_app> docker container run --detach --publish 80:80 --name linux_tweet_app $DOCKERID/linux_tweet_app:1.0
d39667ed1deafc382890f312507ae535c3ab2804907d4ae495caaed1f9c2b2e1
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint linux_tweet_app (a819223be5469f4e727daefaff3e82eb68eb0674e4a46ee1a32e703ce4bd384d): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

I am using Docker Desktop on a Win10 machine locally. I've tried resetting Docker as suggested here. Error persists. Since something else must be using port 80, I should be able to avoid the error by using a different port, right?

PS C:\Users\david.zemens\Source\Repos\linux_tweet_app> docker container run --detach --publish 1337:1337 --name linux_tweet_app $DOCKERID/linux_tweet_app:1.0

Right! docker ps now confirms the container is running:

CONTAINER ID        IMAGE                         COMMAND                  CREATED              STATUS              PORTS                                     NAMES
b700df12c2d1        dzemens/linux_tweet_app:1.0   "nginx -g 'daemon of…"   About a minute ago   Up About a minute   80/tcp, 443/tcp, 0.0.0.0:1337->1337/tcp   linux_tweet_app

But when I try to view the webpage that the tutorial sends me to, I get an error in the browser.

enter image description here

I'm not sure how the link is dynamically generated but it looks something like this:

http://ip172-18-0-32-blsfgt2d7o0g00epuqi0-80.direct.labs.play-with-docker.com/

Browser error as below:

The proxy could not connect to the destination in time.
URL: http://ip172-18-0-32-blsfgt2d7o0g00epuqi0-80.direct.labs.play-with-docker.com/
Failure Description: :errno: 104 - 'Connection reset by peer' on socketfd -1:server state 7:state 9:Application response 502 cannotconnect

Another highly-upvoted answer suggests I need to "disable Windows 10 fast startup" -- I have not tried this yet, mainly because I'm not sure what the full repercussions are with that setting.

Is there something stupidly obvious that I'm overlooking here? Shouldn't I be able to run this on different ports? If not, why not? If I have to use 80:80, but System is already using that port, won't I have some further problems if I try to kill that pid?

PS C:\Users\david.zemens\Source\Repos\linux_tweet_app> netstat -a -n -o | findstr :80 | findstr LISTENING
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:8003           0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       1348
  TCP    0.0.0.0:8081           0.0.0.0:0              LISTENING       4688
  TCP    127.0.0.1:8080         0.0.0.0:0              LISTENING       2016
  TCP    127.0.0.1:8082         0.0.0.0:0              LISTENING       28536
  TCP    [::]:80                [::]:0                 LISTENING       4
  TCP    [::]:8003              [::]:0                 LISTENING       4
  TCP    [::]:8080              [::]:0                 LISTENING       1348
  TCP    [::]:8081              [::]:0                 LISTENING       4688

I made a small change in the Dockerfile changing EXPOSE 80 443 to EXPOSE 1337 443 and I'm now able to view my app by navigating to localhost:1337 in my browser. I think that will get me through the next steps in the training module, but still curious if I'm doing something wrong.

This seems to work regardless of the change in Dockerfile (I've removed and republished after changing Dockerfile).

PS C:\Users\david.zemens\Source\Repos\linux_tweet_app> docker container run --detach --publish 1337:80 --name linux_tweet_app $DOCKERID/linux_tweet_app:1.0

enter image description here

David Zemens
  • 53,033
  • 11
  • 81
  • 130

4 Answers4

45

Try this

> net stop winnat
> docker start ...
> net start winnat
KR93
  • 1,098
  • 11
  • 10
6

A part of the problem is that you're using the wrong mapping. The application uses the port 80, but you're mapping the ports 1337 to 1337.

The correct command should be:

PS C:\Users\david.zemens\Source\Repos\linux_tweet_app> docker container run --detach --publish 1337:80 --name linux_tweet_app $DOCKERID/linux_tweet_app:1.0
Stefano
  • 4,730
  • 1
  • 20
  • 28
  • OK, sorry, so the Dockerfile change I made above was not necessary (seems to work either way???) and I had already done this with ` --publish 1337:80`. That's how I am able to view on localhost:1337 – David Zemens Sep 11 '19 at 16:29
  • I think this solves it, and the link not working on the training website I think is a bug/error on their end unrelated to this. I'll just view output on localhost rather than their custom URL. – David Zemens Sep 11 '19 at 22:31
  • sorry for the late answer, I didn't notice that the browser was open on the right port. I should have paid more attention – Stefano Sep 12 '19 at 06:41
6

It may be because your IIS or some other server is already running on port 80. Try stop the IIS and it should work.

Reference: https://forums.docker.com/t/error-starting-userland-proxy-listen-tcp-0-0-0-0-bind-an-attempt-was-made-to-access-a-socket-in-a-way-forbidden-by-its-access-permissions/81299/7

himanshupareek66
  • 766
  • 10
  • 22
0

Try adding --port-cdn=9002 at the end of the command while you run your project. (9002 can be changed to any other available port.)

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 12 '23 at 00:10