Docker Restart Policy passed through env var
For the last couple of days, I have been tinkering with the publish profile and the Sitecore MVP solution without getting a result that I desire, more about that later but, here is something I managed to achieve/blog since quick-wins keep you going! Here is what I mean:
Right from the day Sitecore 10 Docker official support was released, for the Sitecore github examples, I wanted to have the container restart automatically while I restarted the machine instead of running compose down and up manually. I felt that MVP site would be a good starting point so, today I found sometime to add a .env variable and pass the value dynamically to the docker-compose.yml docker-compose.override.yml as follows. Although this is something simple, it is important to provide developers such an option, allowing devs to switch off if they don't like it:
My var in .env file:
My docker-compose.yml has this new var passed dynamically as follows to all services:
This command should be implemented in docker-compose.override.yml for all the containers except solr-init and sql-init:
Now, once you do a docker-compose up successfully and then shutdown your machine, the next time you start the machine, docker launches your instance automatically.
Although this takes a bit of warm-up time for all containers to go-green, good to see it working automatically on machine startup:
Until all the containers are up and running, accessing the cd instance will throw page not found error:
Once they are all green, and especially when mvp-rendering is running, the cm, cd instances should all be available!
And, if you don't want the restart option, just set it to no (as per the policy values below) in the .env file.
Also, tested the no option passed from .env file:
And on startup, the containers are all grey as expected although you composed up successfully before shutdown:
Comments
Post a Comment