基于docker的centos:latest镜像制作nginx的镜像
Dockerfile和nginx.repo在同一目录下
先创建nginx.repo
[root@localhost nginx]# cat nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@localhost nginx]# ls
Dockerfile nginx.repo
写dockerfile
[root@localhost nginx]# cat Dockerfile
# This is My first Dockerfile
# Version 1.0
# Author: Liuzhengwei
# Base images
FROM centos:base_newlatest
MAINTAINER mail:1135960569@qq.com
ADD nginx.repo /etc/yum.repos.d
RUN yum install nginx -y
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN useradd -s /sbin/nologin -M www
EXPOSE 80
CMD ["nginx"]
创建镜像:
[root@localhost nginx]# docker build -t nginx-file:v1 .
......
Removing intermediate container 57b75e5a35e7
Step 8/8 : CMD nginx
---> Running in 062fddcc03ed
---> f4a750280b72
Removing intermediate container 062fddcc03ed
Successfully built f4a750280b72
运行此镜像:
[root@localhost nginx]# docker run -d -p 80 nginx-file:v1
6e43d596879c2b67fc74143957ef914ef842d78046812717919e576a629f694c
查看容器是否启动正常:
[root@localhost nginx]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e43d596879c nginx-file:v1 "nginx" 7 minutes ago Up 7 minutes 0.0.0.0:32774->80/tcp sleepy_shannon
进入此容器:
[root@localhost nginx]# docker exec -it 6e43d596879c bash
[root@6e43d596879c /]# ps -ef | grep nginx
root 1 0 0 15:58 ? 00:00:00 nginx: master process nginx
nginx 7 1 0 15:58 ? 00:00:00 nginx: worker process
实际示例:
[root@master01 nginx]# ls
Dockerfile fashion_bi_dev.conf nginx.repo web-fashion-bi
[root@master01 nginx]# cat Dockerfile
# This is My first Dockerfile
# Version 1.0
# Author: Liuzhengwei
# Base images
FROM centos
MAINTAINER mail:1135960569@qq.com WORKDIR / RUN mkdir data ADD nginx.repo /etc/yum.repos.d
RUN yum install nginx -y
RUN echo "daemon off;" >> /etc/nginx/nginx.conf RUN rm -rf /etc/nginx/conf.d/default.conf ADD fashion_bi_dev.conf /etc/nginx/conf.d/ COPY web-fashion-bi /data/web-fashion-bi RUN useradd -s /sbin/nologin -M www
EXPOSE 80
CMD ["nginx"]
docker build -t nginx-file:v6 . docker run -d -p 80 nginx-file:v6
[root@master01 nginx]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
46fc3f005313 nginx-file:v6 "nginx" 2 minutes ago Up 2 minutes 0.0.0.0:32773->80/tcp distracted_lovelace

基于docker的centos:latest镜像制作nginx的镜像的更多相关文章
- docker搭建本地仓库并制作自己的镜像
原文地址https://blog.csdn.net/junmoxi/article/details/80004796 1. 搭建本地仓库1.1 下载仓库镜像1.2 启动仓库容器2. 在CentOS容器 ...
- mysql集群基于docker 在centos上
新博客https://blog.koreyoshi.work/ mysql集群(PXC)基于docker 在centos上 常用设计方案 Replication(复制) 速度快 弱一致性 低价值 场景 ...
- 使用centos官方镜像制作jdk8环境镜像
首先将jdk文件或者tar包放在/var/local路径下 然后Dockerfile中写 # 以 centos7 为基础镜像 FROM centos:latest MAINTAINER chen # ...
- 基于官方postgres docker镜像制作自己的镜像
1.Dockerfile FROM library/postgres MAINTAINER wenbin.ouyang #初始化PostgreSQL ENV POSTGRES_USER root EN ...
- Docker 制作Nginx镜像
参考文章:https://www.jianshu.com/p/dc4cd0547d1e 镜像的制作方式有两种,一种是下载别人的镜像之后再制作成自己的镜像,一种是从头开始制作自己的镜像 第一种,下载别人 ...
- Docker学习以及镜像制作流程
一.何为Docker Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后 ...
- Docker系列-(2) 镜像制作与发布
上篇文章引入了Docker的基本原理和操作,本节文章主要介绍如何制作Docker镜像和发布. 镜像文件结构 Docker镜像的本质是一系列文件的集合,这些文件依次叠加,形成了最后的镜像文件,类似于下图 ...
- 《Docekr入门学习篇》——Docker镜像制作
Docker镜像制作 Docker镜像的构建分为两种,一种是手动构建,一种是dockerfile(自动构建) 手动构建 基于centos镜像进行构建制作Nginx镜像 [root@rbtnode1 ~ ...
- docker tomcat镜像制作
推荐使用dockerfile(本文直接拉取tomcat需要进入容器自行安装vim):docker利用Dockerfile来制作镜像 1.查找Docker Hub上的tomcat镜像 [root@loc ...
随机推荐
- pytest文档19-doctest测试框架
前言 doctest从字面意思上看,那就是文档测试.doctest是python里面自带的一个模块,它实际上是单元测试的一种. 官方解释:doctest 模块会搜索那些看起来像交互式会话的 Pytho ...
- Eclipse 报 “Exception in thread "main" java.lang.OutOfMemoryError: Java heap space ”错误的解决办法
1.打开Eclipse软件,选择菜单栏run,在二级菜单中选择 Debug Configurations... 项,如下图所示. 2.在弹出的窗口中选择 (x)=Arguments 选项卡,VM a ...
- [JQuery] jQuery选择器ID、CLASS、标签获取对象值、属性、设置css样式
reference : http://www.suyunyou.com/aid1657.html jQuery是继prototype之后又一个优秀的Javascrīpt框架.它是轻量级的js库(压缩后 ...
- Javascript数组操作及索引
1:清空数组最高效的做法 parentThis.PaperQuestionStrategiesList.length = 0; 2:push and pop parentThis.PaperQue ...
- connection to sys should be as sysdba or sysoper 解决的方法
连接时提示: 出现了例如以下的情况:EXP-00056;遇到ORACLE错误28009. ORA-28009:connection to sys should be as sy ...
- 使用Scala
1. 净资产应用实例 我们要构建这样一个应用,它会取回一份列表,其中包括用户持有的股票的代码以及股份,并告知他们在当前日期为止的这些投资的总价.这包含了几件事:获取用户输入.读文件.解析数据.写文件. ...
- CentOS6.5升级autoconf版本 Autoconf version 2.64 or higher is required
安装软件时提示说需要Autoconf 2.64或更高的版本 [root@BobServerStation twemproxy]# autoconf configure.ac:8: error: Aut ...
- iOS开发-Quartz2D初识
Quartz2D如果单独的从Quartz,那么会发现Quartz是一个开源的Java作业调度框架,单独从英文翻译的角度来看的话Quartz的英文是石英,如果有的时候不小心搜索会发现手表推荐.本文中介绍 ...
- iOS开发-UIApplication和App启动状态
UIApplication简单从字面上了解就是应用程序,开发的时候有的时候会根据需要调用其中的方法,看起来不起眼,实际在iOS开发UIApplication提供了iOS程序运行期间的控制和协作工作.每 ...
- 升级mojave后的小问题解决
首先是xcode没了,我到苹果软件市场上重新下载了一个,可以了. 然后是virtualbox无法打开了,现实版本不兼容,我到官网重新下载了一个最新的6.0.然后就可以正常打开了,并且是无感升级,原来的 ...