Docker图像的更改是否自动转移到部署的容器? [英] Are changes to Docker images automatically transferred to deployed containers?

查看:162
本文介绍了Docker图像的更改是否自动转移到部署的容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据了解,有一个Docker Server托管图像(容器)的应用程序。然后我可以将这些图像部署到我想要的任何基础设施,无论是在本地还是云端。我是对的吗?



假设这个图表





如果我修改了应用程序,只需在Docker Server中修改它们,然后更改将被自动转移?)到部署的容器?或者我需要修改每个实例?

解决方案

码头图像与Class类似。



码头容器与对象相当。



容器是图像的一个实例。



您可以从同一图像运行20个容器。所有20个容器将是相同的(尽管您可以将环境变量传递给每个容器来修改行为)。



图像包含服务(例如Web服务器 - NGINX)



图像包含文件(例如,NGINX将提供的HTML文件)



让我们称此图像XXX



然后,您可以从图像XXX运行一个容器,实际上可以在容器内启动NGINX - 将容器视为虚拟机。



图像的奇妙之处在于它们可以被拉和推并标记(类似于git pull和push)。



所以现在我可以推图像到停靠点集线器,然后从任何地方拉出该图像,然后从该映像运行容器。



现在,我非常快地部署我的Web应用程序。我只是docker拉它,运行一个容器和工作完成。我正在部署的服务器上必须安装的唯一依赖关系是docker本身,没有其他需要。



我可以制作多个图像。例如,我可能有一个前端图像和后端图像。我可以站起来一张两张图像的容器,容器可以互相通话。这使我能够分开担忧。前端代码和从属软件位于一个容器中,后端代码和相关软件位于另一个容器中。



我可能希望在不同的服务器上运行多个前端容器然后站起来一个负载平衡器来将流量引导到这些容器。我甚至可以把负载均衡器放在容器里!这是非常适合扩展,只要确保您的前端容器是无状态的:)



希望有帮助。



请注意,如果您使用多个容器,那么考虑在docker旁边使用docker-compose。 Docker组合基本上只是一个YAML文件,它采用与命令行参数相同的参数。



然而Docker编写提供了一些不错的功能,如docker-compose日志,可以让您查看所有容器的日志。


As I understand, there is a Docker Server hosting images (containers) of the apps. Then I can deploy these images to whatever infrastructure I want, be it locally or cloud. Am I right?

Assume this diagram

If I modify the apps, is it enough to just modify them in the Docker Server, and then the changes will be transferred (automatically?) to the deployed containers? Or do I need to modify each instance?

解决方案

A docker image is comparable to a Class.

A docker container is comparable to an Object.

A container is an instance of an image.

You can run 20 containers from the same image. All 20 containers will be the same (although you could pass environment variables to each container to modify behaviour).

An image contains services (e.g. a web server - NGINX)

An image contains files (e.g. the HTML files NGINX will be serving)

Lets call this image XXX

You can then run a container from image XXX which will actually start NGINX inside the container - think of a container as a virtual machine.

The wonderful thing about images is that they can be pulled and pushed and tagged (similar to git pull and push).

So now I can push an image to docker hub and then pull that image from anywhere and then run containers from that image.

Now it is very quick for me to deploy my web application. I just docker pull it, run a container and job done. The only dependency that must be installed on the server I am deploying too is docker itself, nothing else is required.

I could make multiple images. For example I might have a front end image and a back end image. I can stand up a container for both images and the containers can talk to each other. This allows me to separate concerns. The front end code and dependent software is in one container, the backend code and dependent software is in another container.

I might want to run multiple front end containers on different servers and then stand up a load balancer to direct traffic to those containers. I could even put the load balancer in a container! This is great for scaling, just make sure your front end containers are stateless :)

Hope that helps.

Note if you are using multiple containers then consider using docker-compose alongside docker. Docker compose is basically just a YAML file that takes the same arguments as the command line arguments.

Docker compose however offers a few nice features like docker-compose logs which allows you to view the logs of all containers.

这篇关于Docker图像的更改是否自动转移到部署的容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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