search

Home  >  Q&A  >  body text

docker提交后image过大

我在使用docker构建LNMP环境时,我用docker获取了centos的镜像,然后在centos里构建LNMP的环境,我安装完mysql之后进行了一次commit,完成之后镜像大小时282M,然后我又重新进入yum install了php,完成之后commit了一下,镜像大小就变为了659M,为什么会这样,增长为什么会这么大?

过去多啦不再A梦过去多啦不再A梦2768 days ago800

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-27 09:04:07

    When installing a program through yum, many temporary files will be generated, and many software packages that are not necessarily needed will be installed as recommended software, so the image will naturally become larger.

    In addition, it is best not to run all programs in one container, but to build services through container orchestration.

    reply
    0
  • 世界只因有你

    世界只因有你2017-04-27 09:04:07

    You are using the docker container as a virtual machine. This is incorrect usage. You should use Dockerfile to make the image and follow the best principles for writing Dockerfile.
    For lnmp’s Docker container production, please refer to https://www.centos.bz/2017/02...

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-04-27 09:04:07

    You made the image based on the centos system image, which is equivalent to bundling several images together, so it becomes larger. One program has one image, and then communicates, so it will not be too big.

    reply
    0
  • Cancelreply