1、将Linux整个系统打包成tar文件

cd /root/

tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/dev -cvf centos7-base.tar /


ls

2、导入镜像文件

cat centos7-base.tar | docker import - 10.2.2.2:80/library/nginx-php5:v1.1

docker images

3、Dockerfile制作

3.1 自定义启动shell
start.sh

#!/bin/sh

#启动
/data/app/php-cgi/sbin/php-fpm start
/data/app/nginx/sbin/nginx

# 保持前台运行,不退出
while true
do
    sleep 3600
done

3.2 dockerfile

FROM 10.2.2.2:80/library/nginx-php5:v1.1

# 设置开机启动
####################
COPY start.sh /root/start.sh
RUN chmod +x /root/start.sh


WORKDIR /root

CMD ["/bin/bash","./start.sh"]

EXPOSE 80

3.3 编译新镜像

docker build -t 10.2.2.2:80/library/nginx-php5:v1.2 .

#查看编译后的镜像
docker images |grep php

#推送镜像到仓库
docker push 10.2.2.2:80/library/nginx-php5:v1.2





Logo

更多推荐