title: Python script in Docker container runs fine when called manually not via Docker CLI
body: <p>Sorry if the title is unclear.  I have a custom image that runs a Python script on a loop.  The script continues to run as expected when I call it directly with <code>python3 &lt;script&gt;</code> locally or even in the Docker container that spins up from the image I've built.</p>
  <p>However, when I run the containers via docker-compose, the script does nothing...and when I run it as a <code>docker service</code> or standalone with <code>docker run</code>,  the script runs correctly but only for a short time and then stops.</p>
  <p>Dockerfile:</p>
  <pre><code># syntax=docker/dockerfile:1
  FROM python:3.8-slim-buster
  WORKDIR /mqtt_client
  COPY . .
  RUN pip3 install -r requirements.txt
  CMD [&quot;python3&quot;, &quot;/mqtt_client/mqtt_client.py&quot;]
  </code></pre>
  <p>Any ideas?</p>
  <p>docker-compose snippet:</p>
  <pre><code>py_publisher:
      image: python-mqtt-client
      deploy:
          mode: replicated
          replicas: 3
      depends_on: 
          - broker
      entrypoint: &quot;python3 /path/to/mqtt_client.py&quot;
  </code></pre>
  <p>image directory structure:</p>
  <pre><code>/ &lt;-- root
  .
  ├── Dockerfile
  ├── mqtt_client.py
  └── requirements.txt
  </code></pre>