Hi Prefect Team - We are able to start a docker co...
# ask-community
c
Hi Prefect Team - We are able to start a docker container on our linux box to act as an agent. The agent is started and the work-queue can be started as well. Should we start this docker container from systemd to restart it in case it crashes?
I attempted this, but it failed to start the docker container
Is that the proper way to start the container, or should we start it like this with a docker restart always? sudo docker run -it --restart always prefecthq/prefect:2.10.20-python3.10 /bin/sh -c "prefect cloud login -k *****; prefect agent start -q dev-agent-ny4"
I think this will work when creating a work pool and worker: sudo docker run -t -d --restart always prefecthq/prefect:2.10.20-python3.10 /bin/sh -c "prefect cloud login -k pnb_******; prefect worker start -t docker -p dev-test-ny4-worker --install-policy if-not-present"
n
hi @Chris Gunderson - this might be helpful. yeah systemd is typically what we recommend if you're running a worker (or agent) on a VM if you're just getting set up, I'd recommend a worker, as they are more configurable and designed to be next gen agents
c
@Nate Thanks Nate. I was using this example. I wanted to use a docker container, so we can point to two different workspaces on the same Linux box.
n
i think you could have 2 different systemd services, with different api_urls, which run docker workers. so they'd be regular systemd processes, but the flow runs they submit (for their respective workspace) would be containers
c
@Nate I tried that, but got the failures above.
n
i dont often see people run the worker process itself as a container like that, is there a reason you're doing that? because you have
prefect worker start -t docker
, each flow run will be submitted as a new container to the docker engine available to the worker process, so I'm actually not sure how that would work if the worker process itself is running as a container usually, running the worker as a systemd process that submits flow runs as containers to the VMs docker engine is what I see people doing