美文网首页docker
4.DockerFile初级编写

4.DockerFile初级编写

作者: cooling2016 | 来源:发表于2016-12-28 12:55 被阅读21次

本文是以Ubuntu16.04作为基础镜像,并对此镜像做出一些修改:

修改内容如下:
1.替换镜像源为阿里源。
2.安装curl、wget、vim、nigix、net-tools、iputils-ping 等常用工具。


Dockerfile文件如下所示:

FROM ubuntu:16.04
MAINTAINER jamesz2011 "jamesz2011@126.com"  

USER root

RUN apt-get update

#安装curl和wget远程下载工具
RUN apt-get install -y curl wget

#删除Ubuntu默认的镜像源
RUN rm -f /etc/apt/sources.list

#下载事先上传到taocode上的阿里源文件到tmp目录下
RUN cd /tmp && wget 'http://code.taobao.org/p/ubuntu/src/trunk/sources.list?orig'

#更改阿里源下载文件的名字为sources.list
RUN mv /tmp/sources.list\?orig  /tmp/sources.list

#复制阿里源到Ubuntu的源镜像目录下
RUN cp /tmp/sources.list /etc/apt/

#将阿里源更新到系统中
RUN apt-get update

#安装vim、nigix、net-tools、iputils-ping 等常用工具
RUN apt-get install -y nginx
RUN apt-get install -y vim 
RUN apt-get install -y net-tools 
RUN apt-get install -y iputils-ping
 
#指定端口为80
EXPOSE 80

#执行/bin/bash,方便docker run 时不必输入/bin/bash
CMD /bin/bash





[源文件]

相关文章

网友评论

    本文标题:4.DockerFile初级编写

    本文链接:https://www.haomeiwen.com/subject/tzjyvttx.html