天天看点

使用Dockerfile编译自己的docker镜像

演示一个镜像包含apache

1、新建dockerfile

使用Dockerfile编译自己的docker镜像

vi dockerfile  

 2、填入如下内容

使用Dockerfile编译自己的docker镜像

# version 0.0.1  

from centos  

maintainer "wiselyman"  

run yum -y update  

run yum -y install httpd  

expose 80  

cmd /usr/sbin/apachectl -d foreground  

3、编译

使用Dockerfile编译自己的docker镜像

docker build -t localhost:5000/centos_httpd - < dockerfile  

4、查看

使用Dockerfile编译自己的docker镜像

docker images  

 结果

使用Dockerfile编译自己的docker镜像

repository                                tag                 image id            created             virtual size  

localhost:5000/centos_httpd               latest              53ee0b916001        18 minutes ago      340 mb