手动构建镜像

一、手动构建镜像

  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 [email protected]

思考:

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

猜你喜欢

转载自www.cnblogs.com/Robi-9662/p/10479423.html