将现有的系统打包成Docker镜像文件


https://juejin.im/post/6844903925296922631
https://blog.csdn.net/Deng2012web/article/details/88780212
https://blog.csdn.net/J080624/article/details/104297654
https://www.jianshu.com/p/d9b6bbc7fd77

 


将现有的系统打包成docker容器,用于构建镜像文件

参考文档 
https://www.cnblogs.com/wanzf/p/10623807.html
https://blog.csdn.net/henni_719/article/details/81009449
https://blog.csdn.net/dianhang5567/article/details/101621249

https://blog.csdn.net/weixin_41039041/article/details/84588354
https://blog.csdn.net/qq_26707177/article/details/94157146

https://blog.csdn.net/weixin_47219935/article/details/108720455

https://blog.csdn.net/u013829518/article/details/99681154

 


将现有的系统打包成Docker镜像文件

tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=dev --exclude=run --exclude=boot -cvf /home/JosonDisk/centos7-base.tar /

 

tar --numeric-owner   --exclude=/*.rpm  \

--exclude=/home/JosonDisk  \

--exclude=/usr/share/javadoc  \

--exclude=/usr/lib/jvm \

--exclude=/usr/share/dotnet  \

--exclude=/root/mySQL5.7  \

--exclude=/srv/pentaho-server-ce \

--exclude=/proc \

--exclude=/sys \

--exclude=dev \

--exclude=run \

--exclude=boot -cvf /home/JosonDisk/centos7-base.tar /

 

 

docker import centos7-base.tar centos7
docker run -itd --name JosonCentos centos7:latest /bin/bash

 

如果你的系统装有Docker 打包后,想使用Docker 那么上面语句会报错 

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

首先 docker --version 看 docker 是否 被打包进来了, 然后使用 systemctl status docker 查看具体原因为:

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

那么你需要使用下面语句

docker run -itd  --privileged=true --name JosonCentos centos7:latest  /usr/sbin/init

docker tag centos7 josonjiang/centos7

docker push josonjiang/centos7:latest

 

docker pull josonjiang/centos7:latest

posted @ 2020-08-26 13:17  寒@鹏  阅读(6547)  评论(0编辑  收藏  举报