I have compose.yml
file:
api:
restart: on-failure
command: uvicorn app:app
...
jobs:
restart: on-failure
command: python job.py
...
job.py
:
import asyncio
from prometheus_client import start_http_server
async def background(sio):
await asyncio.gather(...) # <- there are many tasks with while True
start_http_server(5000)
asyncio.run(background(sio))
It works okay. After stopping everything turns off. But when I restart system, jobs
container starting automatically. Why?! api
is not starting, but why jobs
starting?
2
Answers
I think Docker is just trying to run the containers that were running before the system shutdown. Maybe try to change
restart
policy tono
to prevent restarting on startup?According to the documentation
unless-stopped
is probably the right option.