本地源制作docker镜像

本文详细介绍了如何使用febootstrap工具创建并导入CentOS6的镜像,包括镜像的制作、启动及镜像的导出与导入流程。同时解决了在普通用户环境下无法执行超级用户操作的问题,并提供了相应的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先将镜像挂载在本地

[root@zhangxc image]# cat /etc/fstab 
/media/sf_Centos/iso/CentOS-6.6-x86_64-bin-DVD1.iso    /mnt/iso    iso9660    
defaults,loop    0 0

制作镜像

[root@zhangxc image]# febootstrap -i bash -i tar -i openssh-server -i 
yum -i iputils -i iproute -i vim centos6 centos6-image file:///mnt/iso
或者
febootstrap -i bash -i wget -i yum -i iputils -i iproute -i man -i 
vim-minimal -i openssh-server -i openssh-clients centos6 centos6-image 
http://mirrors.aliyun.com/centos/6/os/x86_64/

[root@zhangxc image]# ls
centos6-image

[root@zhangxc image]cd centos6-image/
[root@zhangxc centos6-image]# tar -c .|docker import - centos6-base
9857a3807fd4764016e2f5b30bb95bdb71dfe97a2bf74acdd6e947ef3561794e

[root@zhangxc centos6-image]# docker images     //成功
REPOSITORY          TAG         IMAGE ID     CREATED          VIRTUAL SIZE
centos6-base        latest      9857a3807fd4    7 minutes ago    370.9 MB

启动

[root@zhangxc centos6-image]# docker run -i -t centos6-base /bin/bash
bash-4.1# ls

this finsihed

可能出现的问题:

bash-4.1#

解决:

bash-4.1$
这就代表是普通用户啊
超级用户的标志是#, 普通用户是$

[root@zhangxc centos6-image]# docker run -it zhangxc/centos:base /bin/bash
bash-4.1# su -
[root@de1e42e1bc43 ~]#


vi ~/.bash_profile
编辑这个文件,有时会提示这个文件不存在,直接选edit。
在文件加上
export PS1='[\u@\h \W]\$'
在ssh中vi的保存先按ESC,然后:wq! 保存退出。
最后执行
source ~/.bash_profile
这时shell就可以显示路径了

参考链接http://www.bkjia.com/Linux/884121.html

导出镜像和导入镜像方便分享镜像文件

导出镜像:
docker save IMAGENAME | bzip2 -9 -c>img.tar.bz2
导入镜像(换一台机器):
bzip2 -d -c <img.tar.bz2 | docker load

转载于:https://my.oschina.net/zhangxc73912/blog/402695

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值