<p>I am running two threads inside the container of the Kubernetes pod one thread pushes some data to db and other thread (flask app) shows the data from database. So as soon as the pod starts up main.py(starts both the threads mentioned above) will be called.</p>
<p>Docker file:</p>
<pre><code>FROM python:3

WORKDIR /usr/src/app

COPY app/requirements.txt .

RUN pip install -r requirements.txt

COPY app .

CMD [&quot;python3&quot;,&quot;./main.py&quot;]
</code></pre>
<p>I have two questions:</p>
<ol>
<li><p>Is logs the only way to see the output of the running script? Can't we see its output continuously as it runs on the terminal?</p>
</li>
<li><p>Also, I m not able to run the same main.py file by going into the container. It throws below error:</p>
</li>
</ol>
<pre><code>
Exception in thread Thread-1:
Traceback (most recent call last):
 File &quot;/usr/local/lib/python3.9/threading.py&quot;, line 954, in _bootstrap_inner
  self.run()
 File &quot;/usr/local/lib/python3.9/threading.py&quot;, line 892, in run
  self._target(*self._args, **self._kwargs)
 File &quot;/usr/local/lib/python3.9/site-packages/flask/app.py&quot;, line 920, in run
  run_simple(t.cast(str, host), port, self, **options)
 File &quot;/usr/local/lib/python3.9/site-packages/werkzeug/serving.py&quot;, line 1008, in run_simple
  inner()
 File &quot;/usr/local/lib/python3.9/site-packages/werkzeug/serving.py&quot;, line 948, in inner
  srv = make_server(
 File &quot;/usr/local/lib/python3.9/site-packages/werkzeug/serving.py&quot;, line 780, in make_server
  return ThreadedWSGIServer(
 File &quot;/usr/local/lib/python3.9/site-packages/werkzeug/serving.py&quot;, line 686, in __init__
  super().__init__(server_address, handler) # type: ignore
 File &quot;/usr/local/lib/python3.9/socketserver.py&quot;, line 452, in __init__
  self.server_bind()
 File &quot;/usr/local/lib/python3.9/http/server.py&quot;, line 138, in server_bind
  socketserver.TCPServer.server_bind(self)
 File &quot;/usr/local/lib/python3.9/socketserver.py&quot;, line 466, in server_bind
  self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use (edited)
</code></pre>
<p>How do I stop the <code>main.py</code> script which starts along with the pod and be able to run the main.py from the container itself directly?</p>
<p>Thank you.</p>

Naga sai Kiran
<p>The error message says all:</p>
<pre><code>OSError: [Errno 98] Address already in use (edited)
</code></pre>
<p>It looks like your python script tries to open the same port twice. You cannot do that. Check your code and fix it.</p>
<p>Now answering your other question:</p>
<blockquote>
<p>Is logs the only way to see the output of the running script? Can't we see its output continuously as it runs on the terminal?</p>
</blockquote>
<p>Running <code>kubectl logs -f</code> will follow the logs, which should let you see the output continuously as it runs in terminal.</p>
