docker - Docker for Windows 的端口问题
问题描述
我正在尝试在 training.play-with-docker.com上学习初学者教程。在任务 2,步骤 6,我执行以下操作并收到如下错误:
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.
我在本地 Win10 机器上使用 Docker Desktop。我已尝试按照此处的建议重置 Docker 。错误仍然存在。由于其他东西必须使用端口 80,我应该能够通过使用不同的端口来避免错误,对吧?
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
对! docker ps
现在确认容器正在运行:
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
但是当我尝试查看教程发送给我的网页时,我在浏览器中收到错误消息。
我不确定链接是如何动态生成的,但它看起来像这样:
http://ip172-18-0-32-blsfgt2d7o0g00epuqi0-80.direct.labs.play-with-docker.com/
浏览器错误如下:
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
另一个高度评价的答案表明我需要“禁用 Windows 10 快速启动”——我还没有尝试过,主要是因为我不确定该设置的全部影响。
我在这里忽略了什么愚蠢的明显的东西吗?我不应该能够在不同的端口上运行它吗?如果不是,为什么不呢?如果我必须使用 80:80,但系统已经在使用那个端口,如果我试图杀死那个 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
Dockerfile
我对更改EXPOSE 80 443
进行了小改动,EXPOSE 1337 443
现在可以通过在浏览器中导航到 localhost:1337 来查看我的应用程序。我认为这将使我完成培训模块的后续步骤,但我仍然好奇我是否做错了什么。
Dockerfile
无论更改如何(我在更改 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
解决方案
试试这个
> net stop winnat
> docker start ...
> net start winnat
推荐阅读
- python - 如何在单击按钮reportlab python中打开文件pdf
- spring - 创建名为“registrationController”的 bean 时出错
- bash - 在端口 8080 上运行带有 ssl 的 nginx 服务器,在端口 80/443 上运行 apache2
- python - 如何在 Plotly Express 折线图的轴上以 HH:MM:SS 格式显示时间增量?
- next.js - 接下来使用 auth0 调用 JS API
- django - 如何在 Django 中为 celery beat 设置不同的工作日/周末时间表?
- git - win10 git代理连接中止
- grails - Grails 数据库迁移插件静默失败
- django - Django Rest Framework 自定义权限不起作用
- python - 从输入文件中搜索数据类型