Search code examples
phpdockerproduction

How to quickly switch Docker containers on production?


Imagine that i had created service for uploading kittens pictures and use Docker container on production. To do it I created Docker image with PHP 5.5 service, mounted "upload" folder of my app from real OS and also mounted folder with source code. After some time I decided to improve my app, changed source code and now it requires different env from existed in Docker. For example, now I need PHP 5.6 instead of PHP 5.5

So when I want to change source code of my app, I can do it by switching mounted source code folder with symlinks (or cannot, because Docker will keep socket? If so, how to switch source code? Should I do it right in container without mounting?).

But how can I quickly switch Docker container after switching source code?


Solution

  • Fastest way would be to exec a shell session in the container, update the environment, restart the php service. As you have mounted the source code, no need to switch.

    Best way would be to create a docker image with required environment and stop previous container then run the new image mounting appropriate directories.