上次 利用命令行的形式来构建nginx服务, http://www.cnblogs.com/loveyouyou616/p/6806788.html

这次利用dockerfile文件来构建nginx服务,其实差不多的,学习下 dockerfile的指令即可。

1.建立dockerfile文件

vim Dockerfile

2.编写指令

 #first dockerfile

 FROM ubuntu:latest
MAINTAINER lemon "lemon616@outlook.com"
RUN apt-get update
#RUN apt-get install -y vim
RUN apt-get install -y nginx #指定运行该镜像的容器使用的端口为
# docker run的时候 一定要加上 -P
EXPOSE CMD ["nginx","-g","daemon off;"]

重要指令解释:

第3行 代表后面的所有的指令都依赖于当前设置的镜像 ubuntu:latest

第5-7 安装软件的指令

第13行 创建启动容器的时候执行的命令 , docker run --name nginx/test -d -P images 相当于 docker  docker run --name nginx/test -d -P images nginx -g "daemon off;"

3.创建镜像

docker build -t 新镜像名 .

利用当前目录下的Dockerfile文件创建镜像

   

通过命令可以看到刚才创建的镜像

docker images

4.创建nginx容器

docker run -d -P --name nginx2 lemon/nginx 

访问 32803端口即可 。

通过dockerfile构建nginx的更多相关文章

  1. 使用dockerfile构建nginx镜像

    使用dockerfile构建nginx镜像 docker构建镜像的方法:   commit.dockerfile 1.使用commit来构建镜像: commit是基于原有镜像基础上构建的镜像,使用此方 ...

  2. Dockerfile构建nginx镜像

    Dockerfile构建nginx镜像 [root@bogon ~]# mkdir /opt/docker-file [root@bogon ~]# cd /opt/docker-file/ [roo ...

  3. dockerfile构建nginx并结合php

    转自:https://www.cnblogs.com/jsonhc/p/7799358.html 查看nginx和php的目录结构: [root@docker docker_demo]# tree n ...

  4. 使用dockerfile构建nginx镜像 转

      docker构建镜像的方法:   commit.dockerfile 1.使用commit来构建镜像: commit是基于原有镜像基础上构建的镜像,使用此方法构建镜像的目的:保存镜像里的一些配置信 ...

  5. dockerfile构建nginx

    mkdir docker_demo cd docker_demo wget http://nginx.org/download/nginx-1.2.9.tar.gz vim Dockerfile FR ...

  6. 用Dockerfile构建docker image

    dockerfile是为快速构建docker image而设计的,当你使用docker build 命令的时候,docker 会读取当前目录下的命名为Dockerfile(首字母大写)的纯文本文件并执 ...

  7. docker:构建nginx+php-fpm镜像(一):构建nginx自启动镜像

    步骤一:手动安装nginx环境,并记录全过程: #使用yum更新系统 yum -y update   #下面编译安装tengine,查看有哪些包需要安装 #安装wget包,用于获取安装软件包 yum ...

  8. Docker学习之4——构建NGINX镜像

    Nginx是一个高性能的Web和反向代理服务器,它具有很多非常优越的特性:1.作为Web服务器.2.作为负载均衡服务器.3.作为邮件代理服务器.4.安装及配置简单.接下来我们介绍在docker构建ng ...

  9. Docker容器学习梳理 - Dockerfile构建镜像

    在Docker的运用中,从下载镜像,启动容器,在容器中输入命令来运行程序,这些命令都是手工一条条往里输入的,无法重复利用,而且效率很低.所以就需要一 种文件或脚本,我们把想执行的操作以命令的方式写入其 ...

随机推荐

  1. Ubuntu下Code::Blocks错误

    #error This file requires compiler and library support for the ISO C++ 2011 standard. This support i ...

  2. 对话框(VC_Win32)

    资源描述表中对话框定义 格式: 对话框名 DIALOG[载入特性] X,Y,Width,Height[设置选项] { 对话框控件定义; } 说明: 对话框名称: 标识对话框资源,可为一个字符串也可以为 ...

  3. [ffmpeg_3.3.2]demuxing_decoding.c

    分析ffmpeg3.3.2的example: 由于ffmpeg文档比较少,而且API变化表较大,所以个人首先从ffmpeg自带的demo开始分析,分析(demuxing_decoding.c) 1:首 ...

  4. VC如何得到一个文件夹的路径

    VC中没有现成的函数来选择一个文件夹,但这是经常会用到的,怎么办?自动动手,丰衣足食! 使用SHBrowseForFolder,代码如下: #include   int SelFolder(HWND ...

  5. mysql 解除安全模式

    问题:rror Code: 1175. You are using safe update mode and you tried to update a table without a WHERE t ...

  6. PadLeft 补零

    补零 PadLeft -Caption.Length())+Caption; UnicodeString __fastcall StringOfChar(WideChar Ch, int Count) ...

  7. PuTTY免输密码自动登录Linux

    1.使用PuTTY安装目录里的puttygen.exe工具.先点“生成(Generate)”,然后随意移动鼠标直到进度条填满,即可生成密钥 公钥部分:把上边那一段文字全选->复制备用.(不要点击 ...

  8. linux控制台批量杀进程

    -| cd /app/tomcat8/bin/ ./startup.sh

  9. Buffer I/O error on device sr0

    Buffer I/O error on device sr0, logical block 0 I check today some old CDs, some of them were from ’ ...

  10. DateJsonValueProcessor日期处理

    package com.zjx.controller; import java.text.SimpleDateFormat; import net.sf.json.JsonConfig; import ...