1、输入命令 docker pull nginx:1.15 拉取 nginx 的镜像;

2、使用 docker images 查看拉取到的镜像信息;

3、在主机上创建用于映射的目录

mkdir -p /opt/nginx/config/conf.d
mkdir -p /opt/nginx/logs

4、在 /opt/nginx/config 目录下生成 nginx.conf 文件,文件内容如下:

user  nginx;
worker_processes ; error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid; events {
worker_connections ;
} 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 ;
#gzip on; include /etc/nginx/conf.d/*.conf;
}

5、在 /opt/nginx/config/conf.d 生成 default.conf 文件, 内容如下所示:

server {
listen ;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/host.access.log main; location / {
root /usr/share/nginx/html;
index index.html index.htm;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

6、运行如下的命令

docker run \
--name nginx1. \
-p : \-v /opt/nginx/config/nginx.conf:/etc/nginx/nginx.conf \
-v /opt/nginx/config/conf.d:/etc/nginx/conf.d \
-v /opt/nginx/logs:/var/log/nginx \
-d c82521676580

7、在浏览器找那个打开 http://192.168.172.20:8100,进入到nginx欢迎页面;

Nginx 的 docker 部署的更多相关文章

  1. [DEBUG] QAT Nginx for docker 部署时"--with-ld-opt"出错

    layout: post title: [DEBUG] QAT Nginx for docker 部署时"--with-ld-opt"出错 subtitle: 记一次debug经历 ...

  2. 使用Flask+nginx+uwsgi+Docker部署python应用

    https://www.cnblogs.com/vh-pg/p/11731637.html

  3. 【原创】运维基础之Docker(2)通过docker部署zookeeper nginx tomcat redis kibana/elasticsearch/logstash mysql kafka mesos/marathon

    通过docker可以从头开始构建集群,也可以将现有集群(配置以及数据)平滑的迁移到docker部署: 1 docker部署zookeeper # usermod -G docker zookeeper ...

  4. 【原创】大数据基础之Mesos+Marathon+Docker部署nginx

    一 安装 安装docker:https://www.cnblogs.com/barneywill/p/10343091.html安装mesos:https://www.cnblogs.com/barn ...

  5. Docker部署Nginx并修改配置文件

    Docker部署Nginx并修改配置文件 一.拉取nginx镜像 docker pull nginx 二.在宿主机中创建挂载目录 mkdir -p /data/nginx/{conf,conf.d,h ...

  6. docker 部署nginx 使用keepalived 部署高可用

    一.体系架构 在Keepalived + Nginx高可用负载均衡架构中,keepalived负责实现High-availability (HA) 功能控制前端机VIP(虚拟网络地址),当有设备发生故 ...

  7. docker 部署django项目(nginx + uwsgi +mysql)

    最近在学习用docker部署Django项目,经过百折不挠的鼓捣,终于将项目部署成功,爬过好多坑,也发现很多技能需要提高.特此写下随笔与小伙伴们分享,希望能对大家有所启发. docker的理论我就不赘 ...

  8. Docker部署Nginx应用(2)

    Docker部署Nginx应用(2) 1.拉取Nginx镜像 [root@localhost ~]# docker pull nginx Using default tag: latest lates ...

  9. Docker部署Tomcat,Nginx,Redis应用

    一.tomcat部署 1.拉取tomcat镜像 docker pull tomcat:7-jre7 2创建tomcat容器 创建容器用于部署单点登录系统(CAS)  -p表示地址映射 docker r ...

随机推荐

  1. HttpWatch Professional Edition 7.2.13下载含( license.lic )

    下载地址: http://download.httpwatch.com/httpwatchpro.exe httpwatch.lic     # program.     #     # You ca ...

  2. java语言 找出文章中出现次数最多的单词

    package english; import java.io.File; import java.util.Scanner; import java.io.FileNotFoundException ...

  3. Android无法访问本地服务器(localhost/127.0.0.1)的解决方案

    [Android无法访问本地服务器(localhost/127.0.0.1)的解决方案] 在Android开发中通过localhost或127.0.0.1访问本地服务器时,会报Java.NET.Con ...

  4. HTTP协议之请求

    HTTP请求 组成 一个http请求通常由三个部分组成: 请求行(request line) 首部(header) 主体(body) 格式如下所示 <request-line><CR ...

  5. Java Web开发和Python Web开发之间的区别

    今天的文章讨论了Java Web开发和Python Web开发之间的区别.我不鼓励我们在这里从Java Web迁移到Python Web开发.我只是想谈谈我的感受.它不一定适合所有情况,仅供我们参考. ...

  6. matlab画图标题自定义字体大小

    title('标题','fontname','Times New Roman','Color','b','FontSize',20);字体是Times New Roman,颜色是蓝色('b'即blue ...

  7. pta_l1-6(连续因子)

    题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805138600869888 题意:给定n,求n的最长的连续子因 ...

  8. A class of finite groups with abelian 2-Sylow subgroups By CHIH-HAN SAH

    Remark: 1.An element of a group which conjugate to its inverse is called a real element. If $G$ has ...

  9. OpenCV轮廓vectorvector

    OpenCV轮廓vectorvector,vector,vector,vector https://blog.csdn.net/Ahuuua/article/details/80593388   轮廓 ...

  10. composer windows安装,使用新手入门

    一.前期准备: 1.下载安装包,https://getcomposer.org/download/ 2.在php.ini文档中打开extension=php_openssl.dll 3.下载php_s ...