Can I push application updates to docker image wit

2019-09-14 08:29发布

问题:

Let's say that I have docker image with web server, database server and web application in production.

Can I push applications updates to the production container, without destroying the database server ??

回答1:

I'd recommend reading up on the microservices architecture, because you seem to be making the logical fallacy of equating a Docker image to a lightweight VM image. The logic I use is that VMs isolate an OS from the host, while containers isolates a process and it's children from the host. Therefore, you don't want a web server, database server, and web application on the same image, those would be 2-3 separate images (depending on how your application runs).

Images should be considered immutable, any changes you make to the container should be lost on a full restart. Data is located on volumes, outside of the image and is attached to a container. If you push an update via the data volume, then that change is immediately live without any restart, but you also lose many of the advantages of having versioned immutable images if you move your app into a volume. Whether your containers need to all be restarted together, or if you can pull and replace a single container, or if you can spin up the new version before spinning down the old version to give 100% uptime, depends on the design of your architecture.