Hey everyone, we have a docker agent running on a ...
# ask-community
b
Hey everyone, we have a docker agent running on a cloud vm for our production workloads. We need to automatically restart the docker agent on reboot. Is there a recommended way to make that happen? I stumbled across the https://docs.prefect.io/orchestration/agents/local.html#using-with-supervisor supervisor feature for local agent and am thinking about adapting this for our use case. However, I do not know enough of Supervisor to know if that would be the right approach.
a
@Bastian Röhrig good question - overall local agent and Docker agent both run as a local process, so you can absolutely use the same Supervisor configuration as for a local agent. You need to only adjust the startup command. When you run:
prefect agent local install
, this will output an example
supervisord.conf
config file. You can then copy all that and change:
Copy code
[program:prefect-agent]
command=prefect agent local start
to your agent configuration:
Copy code
[program:prefect-agent]
command=prefect agent docker start --label YOUR_LABEL
b
Thank you, that sounds good 🙂 We will do it like that
👍 1
e
Hi @Bastian Röhrig ! I'm trying to do exactly the same, did you manage to do it ? I have to create a custom VM image and as a complete noob in this field I try to gather as much advice as possible!
a
@Emma Rizzi perhaps you can try first on your local machine? what we do here is a simple supervisor config to make sure the agent process runs in background and is restarted if it gets shut down for some reason
e
@Anna Geller i see it might not be exactly what I need, I'll open a new thread to not spam here!
a
An alternative to using Supervisor is using Docker's own restart policies that you can use to always restart a container if it stops for any reason: https://docs.docker.com/engine/reference/commandline/run/#restart-policies---restart