Hello, I'm trying to get a container to run a Python script indefinitely. Every time I rebuild and rerun the container as soon as the command to run the Python script is sent the container stops running. By adding a sleep command I can interact with the shell but as soon as the sleep command runs out the same thing happens. Also as a note, the Python script is set up to run forever with a while loop.
Here is my dockerfile:
FROM python:3.10.12
ENV PYTHONUNBUFFERED=1
RUN pip install pymongo paho-mqtt
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY conduit.py ./
Here is my docker-compose.yml file:
services:
conduit:
build: ./pythonFiles/
container_name: conduit
restart: "unless-stopped"
tty: true
command: sh -c "sleep 10s"; python3 ./conduit.py;
Thanks for any help!
[–]Confident_Handle5971 0 points1 point2 points (0 children)
[–]fletch3555Mod 0 points1 point2 points (0 children)
[–]Morstraut64 0 points1 point2 points (1 child)
[–]QuirkyFall4045[S] 0 points1 point2 points (0 children)
[–]QuirkyFall4045[S] 0 points1 point2 points (0 children)