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

  • 相关阅读:
    HTTPS缓存
    URL中“#” “?” &“”号的作用
    HTML5开发使用Eclipse通过WIFI调试Android程序
    JS判断鼠标是否在三角形内
    html5开发全屏android软件
    修改织梦自动摘要字数
    HTML5移动开发添加APP启动画面
    AJAX读取模板文件并替换模板中的标签
    感慨一下,2001年的游戏在win8上运行正常!
    PC端利用Xshell连接Android上的Termux
  • 原文地址:https://www.cnblogs.com/zc1741845455/p/10943936.html
Copyright © 2011-2022 走看看