docker download mirror nginx use and access by the public network ip

lab environment:

Excuting an order:

  • docker pull nginx
    //从docker自带的源把nginx的镜像下载下来

  • docker images
    //查看刚才下载的镜像文件

  • docker run -itd --name nginx -p 5555:80 nginx
    //运行刚刚下载nginx的镜像,现在这个镜像是一个容器。修改name为nginx,把本地的5555端口映射到80端口上。

  • docker ps
    //查看启动中的容器,可以看到我们刚刚启动的容器

  • docker exec -it 容器的id /bin/bash
    //进去启动的容器中 /bin/bash是默认的容器存储路径,可以用命令修改。

  • apt-get update
    apt-get install vim
    //进入容器之后,你会发现你没有vim命令,没有办法编辑文件,所以我们要下载一个vim

  • echo "123" >> /usr/share/nginx/html/index.html 
    //修改nginx的首页配置文件(这个配置文件的路径好像不是很固定,这个大家可能需要自己手动的去找一下,我的这个路径仅供大家参考。)

This time, if a friend inside the network, open a Web page directly access your ip

xxx.xxx.xxx.xxx:5555

You can see the nginx has been launched successfully.


  • 登录阿里云管理控制台
    找到网络与安全中的安全组
    在安全组中添加一个规则(没有安全组的就创建一个)
    端口号是5555
    因为我们之前映射的是5555端口
    

  • 访问公网的ip地址查看自己的nginx服务

 

 

 

Because use of the company's ip address, it is not convenient to let everyone see ip.

Here, then it is configured, if upload files, then directly uploaded to the server, and then modify the path to nginx you can directly see the outside network.

Released three original articles · won praise 2 · Views 120

Guess you like

Origin blog.csdn.net/weixin_42431676/article/details/105293329