zoukankan      html  css  js  c++  java
  • 用Docker实现nginx多端口

    一.安装docker

    需要阿里的epel源,需要联网

    [root@bogon ~]#yum -y install docker

    [root@bogon ~]#systemctl start docker

    [root@bogon ~]#systemctl enable docker

    1. 下载httpd镜像

    Docker pull http:2.4.27-alpine     如果镜像本地/root下存放了,可以用docker road < nginx

    1. 运行容器并指定端口

    [root@localhost ~]# docker run -it -p 8001:80 docker.io/nginx /bin/bash

    root@c8931c0b8359:/# nginx

    4查看容器状态

    [root@localhost ~]# docker container ls     或者 docker ps -a

    进入容器里面

    [root@localhost ~]# docker attach 9b

    root@9b38a1021078:/#

    5.在容器安装目录下创建网页

    Yum安装地址放在/usr/share/nginx/html

    源码安装地址放在/usr/local/nginx/htm

    root@c8931c0b8359:/usr/share/nginx/html# ls

    50x.html  index.html

    root@c8931c0b8359:/usr/share/nginx/html# echo 'welocome to beijing' > index.html

    root@c8931c0b8359:/usr/share/nginx/html# [root@localhost ~]#

    [root@localhost ~]# curl 192.168.30.24:8001

    welocome to beijing

    6在容器里可以创建多个端口:8002

    [root@localhost ~]# docker run -it -p 8002:80 docker.io/nginx /bin/bash

    root@9b38a1021078:/# nginx

    root@9b38a1021078:/# [root@localhost ~]#

    [root@localhost ~]# docker container ls

    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES

    9b38a1021078        docker.io/nginx     "/bin/bash"         18 seconds ago      Up 16 seconds       0.0.0.0:8002->80/tcp   stoic_goldwasser

    c8931c0b8359        docker.io/nginx     "/bin/bash"         13 minutes ago      Up 13 minutes       0.0.0.0:8001->80/tcp   kind_booth

    [root@localhost ~]# docker attach 9b

    root@9b38a1021078:/# cd /usr/share/nginx/html/

    root@9b38a1021078:/usr/share/nginx/html# ls

    50x.html  index.html

    root@9b38a1021078:/usr/share/nginx/html# echo 'welocome to shandong' > index.html

    root@9b38a1021078:/usr/share/nginx/html# [root@localhost ~]#

    [root@localhost ~]# curl 192.168.30.24:8002

    welocome to shandong

    [root@localhost ~]# docker ps

    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES

    9b38a1021078        docker.io/nginx     "/bin/bash"         2 minutes ago       Up 2 minutes        0.0.0.0:8002->80/tcp   stoic_goldwasser

    c8931c0b8359        docker.io/nginx     "/bin/bash"         15 minutes ago      Up 15 minutes       0.0.0.0:8001->80/tcp   kind_booth

  • 相关阅读:
    IIS编译器错误信息: CS0016:未能写入输出文件
    asp.net发布到IIS中出现错误:处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
    js 入门
    gridview中 编辑列 要点两次才能出现编辑文本框
    菜鸟解决“子页面关闭刷新父页面局部”问题的历程
    Response.Redirect与Server.Transfer区别
    5天玩转C#并行和多线程编程 —— 第一天 认识Parallel
    C#中在WebClient中使用post发送数据实现方法
    最全面的常用正则表达式大全
    CSS中cursor的pointer 与 hand
  • 原文地址:https://www.cnblogs.com/zc1741845455/p/10943936.html
Copyright © 2011-2022 走看看