zoukankan      html  css  js  c++  java
  • docker使用与nginx搭建

    一. docker使用

      1. docker ps 查看运行中的容器

      2. docker images 查看docker镜像

      3. docker rm id(容器id)  删除容器(容器id可以通过docker ps查看,容器必须停止后才能删除)

        3.1 删除全部的容器 docker rm `docker ps -a -q`

      4. docker stop  id(容器id) 停止容器运行

      5. docker rmi  id(镜像id) 删除镜像

      6. docker pull ubuntu:16.04(镜像名称:版本号) 下载镜像

      7. docker run -it ubuntu:16.04 创建并运行容器容器

        -t 表示在新容器内指定一个伪终端或终端

        -i 表示允许我们对容器内的 (STDIN) 进行交互

        -p 指定映射端口

        -d 在后台运行容器并打印容器ID

        7.1 docker run -dit ubuntu:16.04 创建并后台运行容器

        7.2 docker run -ditp 8080:8080(主机端口:容器端口) ubuntu:16.04 创建并后台运行容器且映射容器的端口

      8. docker attach id(容器id) 进入正在运行中的容器环境

      9. 退出容器

        9.1 exit 直接退出容器并终止容器运行

        9.2 [ctrl+p]+[ctrl+q](快捷键) 退出容器,但是不会终止容器运行

      10. docker commit -m'版本标识' id(容器id) ubuntu:16.04(镜像与版本号)   提交镜像且生成镜像(可以通过该命令把搭建好的容器打包成一个新的镜像或者覆盖原镜像(即是修改原镜像内容,生成的镜像名与版本号相同就可以直接覆盖)) 

    二、 nginx安装与搭建

      1. apt-get install nginx  安装nginx

      2. vim /etc/nginx/nginx.conf(配置文件主要是http这块:一个server代表着一个虚拟服务器)

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    
    events {
            worker_connections 768;
            # multi_accept on;
    }
    
    http {
    
            ##
            # Basic Settings
            ##
    
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 65;
            types_hash_max_size 2048;
            # server_tokens off;
    
            # server_names_hash_bucket_size 64;
            # server_name_in_redirect off;
    
            include /etc/nginx/mime.types;   # 文件类型映射表
            default_type application/octet-stream;
    
            ##
            # SSL Settings
            ##
    
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
            ssl_prefer_server_ciphers on;
    
            ##
            # Logging Settings
            ##
    
            access_log /var/log/nginx/access.log; # 权限相关日志文件保存
            error_log /var/log/nginx/error.log;  # 错误日志文件
    
            ##
            # Gzip Settings
            ##
    
            gzip on;
            gzip_disable "msie6";
    
            # gzip_vary on;
            # gzip_proxied any;
            # gzip_comp_level 6;
            # gzip_buffers 16 8k;
            # gzip_http_version 1.1;
            # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
            ##
            # Virtual Host Configs
            ##
            server {
                    listen 8080;  # 虚拟服务器端口
                    server_name localhost;  # 域名
                    location / {
                            root /home/web;  # web根目录
                            index index.html index.htm index.php;  # 首页匹配
                    }
            }
            include /etc/nginx/conf.d/*.conf;  
            include /etc/nginx/sites-enabled/*;
    }#mail {
    #       # See sample authentication script at:
    #       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    #
    #       # auth_http localhost/auth.php;
    #       # pop3_capabilities "TOP" "USER";
    #       # imap_capabilities "IMAP4rev1" "UIDPLUS";
    #
    #       server {
    #               listen     localhost:110;
    #               protocol   pop3;
    #               proxy      on;
    #       }
    #
    #       server {
    #               listen     localhost:143;
    #               protocol   imap;
    #               proxy      on;
    #       }
    #}

      3. nginx -c /etc/nginx/nginx.conf(配置文件路径)   根据配置文件启动nginx服务

      4. service nginx start 启动nginx服务

      5. service nginx stop 停止nginx服务

      6. service nginx restart 重启nginx服务

  • 相关阅读:
    Runloop运行循环的理解
    GCD dispatch_apply基本使用
    GCD信号量semaphore控制线程并发数
    多线程GCD dispatch_once_t/dispatch_barrier_<a>sync/dispatch_group_t
    iOS开发常用宏定义
    OC方法可变参数
    GCD的基本使用
    iOS实用小工具
    项目中实用第三方框架
    NSTimer内存泄漏问题
  • 原文地址:https://www.cnblogs.com/dudeyouth/p/6678695.html
Copyright © 2011-2022 走看看