• docker 创建nginx容器部署前端服务


    1、搜索nginx镜像

    docker search nginx

    2、拉取镜像

    docker pull nginx名称

    3、创建test镜像

     docker run --name nginx-test -p 8080:80 -d nginx

    4、访问宿主ip和端口,查看 nginx

    5、从nginx-test测试容器中拷贝文件到宿主机

    docker cp nginx-test:/etc/nginx/nginx.conf /home/nginx/copadmin

     5、nginx目录挂在,必须在宿主机上有nginx.conf 文件才可以挂在,所以在宿主进上创建  /nginx/config/nginx.conf配置文件,配置文件如下

    user nginx;
    worker_processes auto;
    
    error_log /var/log/nginx/error.log notice;
    pid /var/run/nginx.pid;
    
    
    events {
    worker_connections 1024;
    }
    
    
    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
    
    access_log /var/log/nginx/access.log main;
    
    sendfile on;
    #tcp_nopush on;
    
    keepalive_timeout 65;
    
    #gzip on;
    
    include /etc/nginx/conf.d/*.conf;
    
    
    server {
    listen 8081;
    server_name 10.9.53.58;
    
    #charset koi8-r;
    
    location / {
    proxy_pass http://www.badu.com;
    #root /home/copfront/copfront.admin/dist;
    #index index.html index.htm;
    }
    
    #error_page 404 /404.html;
    
    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ .php$ {
    # proxy_pass http://127.0.0.1;
    #}
    
    
    }
    
     
    
    }

    6、构建镜像,并目录挂载

    docker run --name cop.admin.web -p 8001:80 -v /home/nginx/copadmin/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx -v /home/copfront/copfront.admin/:/usr/share/html -d nginx

    7、将打包好的前端页面直接放到对应的copfront.admin文件夹内就可以了

    8、重启docker 容器

  • 相关阅读:
    微信自动回复
    pyqt5生成的APP制作DMG
    win10 安装MySQL过程和遇到的坑
    CentOS7 虚拟机设置文件共享 VMWareTools安装遇到的坑
    阿里云配置ssl证书服务遇到的几个问题和解决方法
    Linux基于libmemcached,php扩展memcached的安装
    PHP框架CodeIgniter--URL去除index.php
    javascript新窗口打开链接window.open()被阻拦的解决办法
    Centos6.5源码编译安装nginx
    MySQL批量修改数据库的字符集
  • 原文地址:https://www.cnblogs.com/cyit/p/15152401.html
Copyright © 2020-2023  润新知