手动构建镜像

一、手动构建镜像

  docker commit 命令是创建新镜像最直观的方法,其过程包含三个步骤:

   1. 运行容器

  2. 修改容器

  3. 将容器保存为新的镜像

  官方的centos镜像没有vim 编辑工具,如何添加? 按照上面的步骤完 成添加,并创建新镜像 centos-with-vim

  1.1   例子一:

  # docker run -it centos [root@d26b3fe5529f /]

  # yum install -y vim

  # docker commit d26b3fe5529f centos-with-vim

  # docker images

   # docker run -it centos-with-vim [root@179ec4d48d88 /]

  # which  vim /usr/bin/vim

  1.2  例子二:

    root@179ec4d48d88 /]#  yum install passwd openssl openssh-server iproute iproute-doc -y

    [root@179ec4d48d88 /]#  /usr/sbin/sshd -D
    [root@179ec4d48d88 /]# ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '’

     [root@179ec4d48d88 /]# ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '’

    [root@179ec4d48d88 /]# ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''

    [root@179ec4d48d88 /]# vim /etc/ssh/sshd_config UsePAM yes 改为 UsePAM no UsePrivilegeSeparation sandbox 改为 UsePrivilegeSeparation no

    [root@179ec4d48d88 /]# passwd root
    [root@docker-01 ~]# ssh root@172.30.5.2

思考:

    制作一个centos 7的镜像, 更新yum源为阿里的yum源,将制作过程截图, 并上传git hub。

转载于:https://www.cnblogs.com/Robi-9662/p/10479423.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值