与docker搭配使用时如何更改nginx的端口 [英] How to change the port of nginx when using with docker

查看:634
本文介绍了与docker搭配使用时如何更改nginx的端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是docker初学者,我做的第一件事是下载nginx并尝试将其安装在80:80端口上,但Apache已经坐在那里。

I am a docker beginner and the first thing i did was download nginx and tried to mount it on 80:80 port but Apache is already sitting there.

docker container run --publish 80:80 nginx

docker container run --publish 3000:3000 nginx

我尝试这样做3000:3000在端口上使用它3000,但它不起作用。它也不记录任何我可以用来参考的东西。

I tried doing it like this 3000:3000 to use it on port 3000 but it doesn't work .And it doesn't log anything either which i could use for referance.

推荐答案

从Docker开始,您可能会在DockerHub上找到有关映像的有用信息。例如,使用nginx,您将获得有关如何公开公共端口的章节。

When you're starting with Docker you may find helpful information about images at DockerHub. For example with nginx you have a section about how to expose public ports.

您可以使用:

docker run --publish 3000:80 nginx

您本地主机中的端口3000将转发到端口80,这是nginx映像用来等待的端口http连接。

Port 3000 in your localhost will be forwarded to port 80 which is the port that nginx images use to wait for http connections.

我还建议您阅读以下官方文档关于Docker中的联网

I also recommend you to read these official docs about networking in Docker.

这篇关于与docker搭配使用时如何更改nginx的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆