Docker 启动 Nginx

拉取镜像

docker pull nginx:1.17.9

启动步骤

# 创建 nginx 目录
mkdir -p /usr/local/nginx && cd /usr/local/nginx # 映射配置目录
mkdir -p /usr/local/nginx/conf.d

如果映射 conf.d 目录,该文件下默认的 default.conf 文件就没有了。无法正常启动。

需要创建 /usr/local/nginx/conf.d/default.conf 作为启动配置,下面是一个示例:

server {
listen 80;
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 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;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# 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;
#}
}

启动容器

# 启动容器
docker run \
--name nginx-test \
-v ${PWD}/conf.d:/etc/nginx/conf.d \
-p 8081:80 \
-d nginx:1.17.9

访问

http://host:8080/

可以看到

Docker 启动 Nginx的更多相关文章

  1. docker 启动 nginx 访问不了的问题

    使用版本:nginx version: nginx/1.13.8 正使用docker启动nginx容器的时候,一切都很正常,容器也起来了 docker run -dit -p 80:80 --name ...

  2. docker 启动 nginx 服务

    docker run -d -p 80:80 --restart=always nginx:latest 参数说明: run 启动某个镜像 -d 让容器在后台运行 -p 指定端口映射,宿主机的80端口 ...

  3. Docker学习笔记--Docker 启动nginx实例挂载目录权限不够(转)

    今天在启动一个docker 运行nginx实例,在挂载目录时,出现访问静态目录时,权限不够 执行的命令是: docker run --name my-nginx -d -p 80:80 --resta ...

  4. linux下docker启动nginx无法访问80端口

    问题: Linux安装了docker,docker启动了一个nginx容器,通过 80 端口无法正常访问 故障排查: 1.检查 nginx 容器启动的命令或者yaml文件,查看是否有跟本机端口进行绑定 ...

  5. docker启动nginx的ssl配置

    前提条件 一台云服务器(阿里云.腾讯云等的centOS) 服务器上面要有docker(安装方法这里不做介绍) 一个域名 ssl证书(两个文件:一个key后缀,一个pem后缀:生成方法很多这里不再介绍) ...

  6. docker 启动redis/nginx

    1.docker 启动redis   # redis docker run -itd --name redis-test -p 16379:6379 redis   2.docker 启动nginx ...

  7. 【转载】Docker 安装 Nginx 并个性化挂载配置文件 nginx.conf

    首先,系统(3.8以上内核的linux)中安装好 Docker 这个运用程序.由于网络原因,我们下载一个Docker官方的镜像需要很长的时间,甚至下载失败.为此,阿里云容器镜像服务提供了官方的镜像站点 ...

  8. 在win10 docker启动的centos容器中安装nginx

    我是在win10机器上搭建了一个docker,在docker启动了centos容器,在centos中安装nginx. 安装配置docker 直接在官网下载docker for windows:http ...

  9. docker上启动nginx,并配置修改nginx的配置文件

    1.使用docker 下载nginx 镜像  docker pull nginx 2.启动nginx docker run --name nginx -p 80:80 -d nginx 这样就简单的把 ...

随机推荐

  1. How to use the function of bind

    The usage of  bind  is to define a specified scope for called function. Because the key this is easy ...

  2. bzoj2016[Usaco2010]Chocolate Eating*

    bzoj2016[Usaco2010]Chocolate Eating 题意: n块巧克力,每次吃可以增加ai点快乐,每天早晨睡觉起来快乐值会减半,求如何使d天睡觉前的最小快乐值最大.n,d≤5000 ...

  3. Kafka 信息整理

    请说明什么是传统的消息传递方法? 传统的消息传递方法包括两种: ·排队:在队列中,一组用户可以从服务器中读取消息,每条消息都发送给其中一个人. ·发布-订阅:在这个模型中,消息被广播给所有的用户. 为 ...

  4. Crawlab Lite 正式发布,更轻量的爬虫管理平台

    Crawlab 是一款基于 Golang 的分布式爬虫管理平台,产品发布已经一年有余,经过开发团队的不断打磨,即将迭代到 v0.5 版本.在这期间我们为 Crawlab 加入了大量社区用户共同期望的功 ...

  5. Python Ethical Hacking - MODIFYING DATA IN HTTP LAYER(2)

    MODIFYING DATA IN HTTP LAYER Edit requests/responses. Replace download requests. Inject code(html/Ja ...

  6. 10种常见OOM分析——手把手教你写bug

    点赞+收藏 就学会系列,文章收录在 GitHub JavaKeeper ,N线互联网开发必备技能兵器谱,笔记自取 在<Java虚拟机规范>的规定里,除了程序计数器外,虚拟机内存的其他几个运 ...

  7. 【翻译】.NET 5 Preview7发布

    今天,发布了.NET 5.0 Preview7.这是倒数第二个预览版本(在转移到RC之前).此时,大多数功能应该已经非常接近完成了.Single file和ARM64 intrinsics是两个花费了 ...

  8. CentOS7编译安装php7.1配置教程详解

    这篇文章主要介绍CentOS7编译安装php7.1的过程和配置详解,亲测 ,需要的朋友可以参考. 1.首先安装依赖包: yum install libxml2 libxml2-devel openss ...

  9. vue图片上传的简单组件

    <template> <div class="rili" id="rili"> <div class="updel&qu ...

  10. Dart语言之 异步支持

    Dart类库有非常多的返回Future或者Stream对象的函数. 这些函数被称为异步函数:它们只会在设置好一些耗时操作之后返回,比如像 IO操作.而不是等到这个操作完成. async和await关键 ...