<p>I'm trying to follow instructions on this <a href="https://kubernetes.io/docs/tutorials/hello-minikube/" rel="nofollow noreferrer">guide</a> but under docker.</p>
<p>I set up a folder with:</p>
<pre><code>.
├── Dockerfile
└── main.py
0 directories, 2 files
</code></pre>
<p><code>main.py</code> is:</p>
<pre><code>#!/usr/bin/env python3

print(&quot;Docker is magic!&quot;)
</code></pre>
<p>Dockerfile is:</p>
<pre><code>FROM python:latest
COPY main.py /
CMD [ &quot;python&quot;, &quot;./main.py&quot; ]

FROM python:3.7-alpine
COPY ./ /usr/src/app/
WORKDIR /usr/src/app
RUN apk add curl openssl bash --no-cache
RUN curl -LO &quot;https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl&quot; \
    &amp;&amp; chmod +x ./kubectl \
    &amp;&amp; mv ./kubectl /usr/local/bin/kubectl


kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4

kubectl expose deployment hello-node --type=LoadBalancer --port=38080

minikube start --driver=docker

kubectl get pods
</code></pre>
<p>When I run docker run python-test I see in terminal:</p>
<pre><code>Docker is magic!
</code></pre>
<p>but I don't see the get pods output.</p>
<p>My goal here is to run a simple <code>minikube</code> in the docker that just print the list of the pods. What is wrong here?</p>

<p>If you want to use kubernetes inside a docker container my suggestion is to use k3d .</p>
<blockquote>
<p>k3d is a lightweight wrapper to run k3s (Rancher Lab’s minimal Kubernetes distribution) in docker.k3d makes it very easy to create single- and multi-node k3s clusters in docker, e.g. for local development on Kubernetes.</p>
</blockquote>
<p>You can Download , install and use it directly with Docker.
For more information you can follow the official documentation from <a href="https://k3d.io/" rel="nofollow noreferrer">https://k3d.io/</a> .</p>
<p>To get the list of pods you dont' need to create a k8s cluster inside a docker container .
what you need is a config file for any k8s cluster
.
├── Dockerfile
├-- config
└── main.py
0 directories, 3 files</p>
<p>after that :</p>
<pre><code>FROM python:latest
COPY main.py /
CMD [ &quot;python&quot;, &quot;./main.py&quot; ]

FROM python:3.7-alpine
COPY ./ /usr/src/app/
WORKDIR /usr/src/app
RUN apk add curl openssl bash --no-cache
RUN curl -LO &quot;https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl&quot; \
    &amp;&amp; chmod +x ./kubectl \
    &amp;&amp; mv ./kubectl /usr/local/bin/kubectl

COPY config ~/.kube/config
# now if you execute k get pods you can get the list of pods
#Example;
RUN kubectl get pods 

</code></pre>
<p>to get this file config you can follow this link <a href="https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/" rel="nofollow noreferrer">Organizing Cluster Access Using kubeconfig Files</a></p>
<p>I hope that can help you to resolve your issue .</p>
