从现有虚拟机创建Docker映像

从现有虚拟机创建Docker映像

本文介绍了从现有虚拟机创建Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用CentOS和MySQL创建docker基本映像。但是我已经有了这样的VM(没有docker)。我如何才能从此现有VM创建基础docker映像,并在带有docker的另一台计算机上将其创建?

I need to create docker base image with CentOS and MySQL. But I already have such VM (without docker on it). How can I create base docker image from this existing VM and you it on another machine with docker?

推荐答案

其他评论者有正确指出,将VM导入Docker不是创建映像的预期方式,这可能,并且可以为您提供一个在完全提交之前测试事物的快速起点。为此,您只需配置一个Linux根文件系统(在您的情况下为:您的CentOS VM)并将其流式传输到docker import中,如下所示:

While the other commenters have pointed out correctly that importing a VM into Docker is not the intended way to create images, it is possible and can provide you with a fast starting point to test things before you fully commit. To do this, you simply provision a linux root file system (in your case: your CentOS VM) and stream it into docker import like so:

tar -cC [folder containing provisioned root fs] . | docker import - [image name]

包含更多信息,甚至链接到用于创建CentOS基本映像的脚本。

Docker's base image documentation has more info and even links to a script to create a CentOS base image.

这篇关于从现有虚拟机创建Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 16:01