我该如何对现有应用程序进行泊坞操作...基础知识 [英] How do I dockerize an existing application...the basics

查看:58
本文介绍了我该如何对现有应用程序进行泊坞操作...基础知识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了很多youtube视频并阅读了所有docker文档.但是我仍然没有得到阻止我了解docker的核心概念. 我正在使用Windows并安装了boot2docker.我已经从docker hub下载了图像并运行了基本命令.但 我如何将现有的应用程序放在本地计算机上(为简单起见,只说它有一个文件"index.php").我该如何将其放入docker映像中并运行它?

I've watched a ton of youtube videos and read all of the docker docs. However I still do not get a core concept that is stopping me from understanding docker. I am using windows and have boot2docker installed. I've downloaded images from docker hub and run basic commands. BUT How do I take an existing application sitting on my local machine (lets just say it has one file 'index.php', for simplicity). How do I take that and put it into a docker image and run it?

推荐答案

您的index.php并不是真正的应用程序.该应用程序是您的Apache或nginx甚至是PHP自己的服务器.

Your index.php is not really an application. The application is your Apache or nginx or even PHP's own server.

由于Docker使用Windows内核中不提供的功能,因此您正在实际的虚拟机中运行它.这样做的唯一目的是为您的真实服务器环境训练或准备映像.

Because Docker uses features not available in the Windows core, you are running it inside an actual virtual machine. The only purpose for that would be training or preparing images for your real server environment.

对于Docker,您需要了解两个主要概念:图像和容器.

There are two main concepts you need to understand for Docker: Images and Containers.

图像是由图层组成的模板.每层仅包含前一层与某些脱机系统信息之间的差异.每层实际上都是一幅图像.您应该始终使用 Dockerfile (

An image is a template composed of layers. Each layer contains only the differences between the previous layer and some offline system information. Each layer is fact an image. You should always make your image from an existing base, using the FROM directive in the Dockerfile (Reference docs at time of edit. Jan Vladimir Mostert's link is now a 404).

容器是已运行或当前正在运行的图像的实例.创建容器(也称为运行映像)时,您可以将内部目录映射到外部.如果两个位置都有文件,则外部目录将覆盖映像内部的文件,但这些文件不会丢失.要恢复它们,您可以容器提交到映像中(最好是在将其停止后),然后从新映像中启动一个新容器,而无需映射该目录.

A container is an instance of an image, that has run or is currently running. When creating a container (a.k.a. running an image), you can map an internal directory from it to the outside. If there are files in both locations, the external directory override the one inside the image, but those files are not lost. To recover them you can commit a container to an image (preferably after stopping it), then launch a new container from the new image, without mapping that directory.

这篇关于我该如何对现有应用程序进行泊坞操作...基础知识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆