<p>I have a simple python code, but I can't get it running on Docker nor Kubernetes.</p>

<p>I'm building, tagging and pushing my image and than running</p>

<pre><code>docker build -t test . --no-cache
docker tag test tcnl/test:0.2
docker push tcnl/test
docker run tcnl/test:0.2
</code></pre>

<pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python

# WS server example
print("Listening...")
import socket
print("Listening...")
import sys
print("Listening...")

s = socket.socket()
print("Listening...")
host = "0.0.0.0"
port = 8765
s.bind((host, port))
print("Listening...")
s.listen(5)
print("B4 while")
try:

    c, addr = s.accept()
    while True:
        print("INSIDE TRUE")
        print('Got connection from', addr)
        c.send(("Connection accepted!").encode('utf-8'))
        print(str(c.recv(4096).decode('utf-8')))
except:
    print("Oops!",sys.exc_info(),"occured.")
    input()
s.close()
</code></pre>

<p>It's meant to be just a websocket server, waiting for a connection an then just send messages. But not even that is working...
Now my Dockerfile</p>

<pre><code>FROM python:3.6
MAINTAINER tcnl

# Creating Application Source Code Directory
RUN mkdir -p /test/src

# Setting Home Directory for containers
WORKDIR /test/src

# Installing python dependencies
COPY ./requirements.txt /test/src/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copying src code to Container
COPY ./test-server.py /test/src/test.py

# Application Environment variables
ENV APP_ENV development

# Exposing Ports
EXPOSE 8765

# Setting Persistent data
VOLUME ["/test-data"]

# Running Python Application
CMD python /test/src/test.py
</code></pre>

<p>When I run on docker the program doesn't even print. What am I doing wrong?</p>

Thiago Casa Nova
<p>Just run <code>docker run -it tcnl/test:0.2</code> it would bind docker stdout to your terminal and you will see output:</p>
<h1>Docker</h1>
<pre><code># docker run -it tcnl/test:0.2
Listening...
Listening...
Listening...
Listening...
Listening...
B4 while
</code></pre>
<h1>Kubernetes</h1>
<p><code>kubectl run -it test-server --restart=Never --image=tcnl/test:0.2</code></p>
<p>To get output:
<code>kubectl logs test-server</code></p>
<pre><code>Listening...
Listening...
Listening...
Listening...
Starting Flask...
Listening...
B4 while
</code></pre>
