Docker 安装并定制 Nginx 服务器
安装并定制 Nginx
1、查阅对应的官方文档,首先下载镜像文件:
[spider@izwz9d74k4cznxtxjeeur9z local]$ sudo docker pull nginx
[sudo] password for spider:
Sorry, try again.
[sudo] password for spider:
Using default tag: latest
Trying to pull repository docker.io/library/nginx ...
latest: Pulling from docker.io/library/nginx
177e7ef0df69: Already exists
ea57c53235df: Pull complete
bbdb1fbd4a86: Pull complete
Digest: sha256:b543f6d0983fbc25b9874e22f4fe257a567111da96fd1d8f1b44315f1236398c
Status: Downloaded newer image for docker.io/nginx:latest
2、定制 Nginx
1、从容器中拷贝一份默认配置
首先在自己的主机上创建目录/etc/docker/nginx用于存放定制 nginx 的配置文件:
[spider@izwz9d74k4cznxtxjeeur9z ~]$ sudo mkdir -p /etc/docker/nginx
接着新运行一个容器,并从其中拷贝出nginx.conf:
[spider@izwz9d74k4cznxtxjeeur9z ~]$ sudo docker run --name tmp-nginx -d nginx
bb807eb140b85570258f834043560b37c16a655821a120273d49cc9369e45067
[spider@izwz9d74k4cznxtxjeeur9z ~]$ sudo docker cp tmp-nginx:/etc/nginx/nginx.conf /etc/docker/nginx/nginx.conf
将临时创建的容器删除:
[spider@izwz9d74k4cznxtxjeeur9z ~]$ sudo docker rm -f tmp-nginx
[sudo] password for spider:
tmp-nginx
2、使用定制的 nginx.conf 启动容器
[spider@izwz9d74k4cznxtxjeeur9z ~]$ sudo docker run --name mynginx -v /etc/docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
607b0f8096011829dd4cdea89270a7707bea003fac08e7516559713fb838de1e
[spider@izwz9d74k4cznxtxjeeur9z ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
607b0f809601 nginx "nginx -g 'daemon ..." 12 seconds ago Up 11 seconds 80/tcp mynginx
到这一步,就算定制完了,如果我们要修改Nginx 服务器的配置,只需修改我们主机上的nginx.conf,然后重新启动容器就可以了。
Docker 安装并定制 Nginx 服务器的更多相关文章
- docker安装并修改Nginx镜像
1.安装nginx镜像,命令:docker pull nginx 2.创建nginx容器,并启动,命令:docker run --name webserver -d -p 192.168.51.227 ...
- ubuntu14.04安装与配置nginx服务器
去年曾经配置过nginx服务器,可惜的是,几个月前因故障磁盘被格式化.今天又要用到nginx服务,所以从新配置了一番,但这次就不是那么顺利了.在此,愿与大家分享一下经验.只是简单的局域网应用,并未复杂 ...
- Centos7使用Docker安装Gogs搭建git服务器
gihub地址:https://github.com/gogs/gogs gogs官网:https://gogs.io/ gihub官方docker安装gogs方法:https://github.co ...
- docker安装与配置nginx详细过程
注:大鸟飞过,此方式只用于快速搭建使用 第一步 pull nginx 命令:docker pull nginx 第二步 启动nginx 命令:docker run --name nginx -p 80 ...
- docker一分钟搭建nginx服务器
运行nginx服务 拉取: docker pull nginx:1.17.9 运行: docker run -d --name nginx -P 80:80 nginx:1.17.9 -d表示在后台启 ...
- Docker安装Mysql和Nginx
1. 序言 将应用容器化更方便于管理,昨天辛辛苦苦安装在宿主机上的,今天狠心重置服务器,学下docker练练手. 2. Get start 2.1 安装Docker 公司的云用的是ubuntu,我自己 ...
- Docker安装mysql、nginx、redis、tomcat
拉取mysql 5.7官方镜像 docker pull mysql:5.7 启动容器 docker run --name mysql5.7 -p 3306:3306 -e MYSQL_ROOT_PAS ...
- docker安装和配置nginx
配置nginx docker配置nginx 本机ip是192.168.0.200 docker pull nginx 配置nginx主机 vi /root/docker/nginx/nginx01.c ...
- docker安装部署PHP nginx
sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=htt ...
随机推荐
- Codeforces Round #344 (Div. 2) E. Product Sum 二分斜率优化DP
E. Product Sum Blake is the boss of Kris, however, this doesn't spoil their friendship. They often ...
- node.js 在函数内获取当前函数
js 如何在函数体内部知道 自己在哪个函数内运行呢? 打比方: function a() { // 我想在这里知道我的函数名a和函数function a () {...} } 使用Error的调用栈可 ...
- a non-linear editing software
VLMC, open source video editor - VideoLAN http://www.videolan.org/vlmc/
- c# IP从192.168.1.1转成int类型
找了一些资料,总结如下: 方法1 .net提供的方法转换IP地址 //字符串转换为数字 System.Net.IPAddress ipaddress = System.Net.IPAddress.Pa ...
- 51Nod 1450 闯关游戏 —— 期望DP
题目:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1450 期望DP: INF 表示这种情况不行,转移时把不行的概率也转 ...
- bzoj2763 [JLOI2011]飞行路线——分层图
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2763 构建分层图. 代码如下: 写法1(空间略大)(时间很慢): #include<i ...
- 11.Extjs登录页面js
/** * @author sux * @desc 登录 */ Ext.onReady(function(){ Ext.QuickTips.init(); //错误信息显示必须 var loginFo ...
- http-2.4
http-2.4 1)新特性 (1)MPM 支持运行为DSO 机制:以模块形式按需加载 (2)event MPM 生产环境可用 (3)异步读写机制 (4)支持每模块及每目录的单独日志级别定义 (5)每 ...
- CodeForces 731F Video Cards (数论+暴力)
题意:给定 n 个数,可以对所有的数进行缩小,问你找出和最大的数,使得这些数都能整除这些数中最小的那个数. 析:用前缀和来做,先统计前 i 个数中有有多少数,然后再进行暴力去找最大值,每次都遍历这一段 ...
- Commons-FileUpload 文件上传(模板)
// 创建FileItem工厂函数 FileItemFactory FIF = new DiskFileItemFactory(); // 获取ServletFileUpload对象,使用工厂实例传入 ...