CentOS 6.5 制作ubuntu 12.04的docker镜像

安装docker请看这里:http://my.oschina.net/feedao/blog/222306

前面的文章http://my.oschina.net/feedao/blog/222699,我们创建了centos镜像,这次我们要在

CentOS上制作ubuntu镜像

方法如下:

root:

yum -y install debootstrap

cd /home/admin/

第一次执行:

debootstrap --arch amd64 precise ubuntu-precise http://mirrors.163.com/ubuntu/

报错:no such script /usr/share/debootstrap/scripts/precise
解决办法:
ln -s /usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/precise

再次执行:

debootstrap --arch amd64 precise ubuntu-precise http://mirrors.163.com/ubuntu/

修改权限:

chown -R admin.admin ubuntu-precise

切换成admin用户:

su admin

[admin@localhost ~]$ cd ubuntu-precise/

制作ubuntu镜像

[admin@localhost ubuntu-precise]$ tar -c .|docker import - ubuntu1204-base
43ad1b1116dd81b704fddcb803cf5267e6f66f2dd7751b5d2248495f97443705

查看镜像:

[admin@localhost ubuntu-precise]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
ubuntu1204-base     latest              43ad1b1116dd        About a minute ago   172.7 MB
centos63-bash       latest              d2ecedd2b5ed        About an hour ago    306.7 MB

创建ubuntu容器:

[admin@localhost ubuntu-precise]$ docker run -t -i ubuntu1204-base /bin/bash
root@8053e2ca797b:/# pwd
/
root@8053e2ca797b:/# exit
exit

查看当前容器:

[admin@localhost ubuntu-precise]$ docker ps -a
CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS                         PORTS               NAMES
8053e2ca797b        ubuntu1204-base:latest   /bin/bash           31 seconds ago      Exited (0) 2 seconds ago                           thirsty_thompson    
14c9afaf2f06        centos63-bash:latest     /bin/bash           About an hour ago   Exited (0) About an hour ago                       insane_lalande     

重新启动和进入ubuntu容器:

[admin@localhost ubuntu-precise]$ docker start 8053e2ca797b
8053e2ca797b
[admin@localhost ubuntu-precise]$ docker attach 8053e2ca797b
root@8053e2ca797b:/# ls
bin   dev  home  lib64 mnt  proc  run selinux  sys  usr
boot  etc  lib media opt  root  sbin  srv  tmp  var

在docker里面运行的ubuntu基础镜像就制作成功了。

 

转载于:https://my.oschina.net/feedao/blog/222767

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值