<p>I ran docker image with the following command:</p>

<pre><code>sudo docker run -dit --net mynetwork read_and_send_apps_logs:latest
</code></pre>

<p>Now I use Kubernetes to run the image. The problem is that I don't know where to define the --net in kubernetes?</p>

<p>Can I define it in the deploy yaml, or when running <code>$kubectl create -f &lt;...&gt;</code> ?</p>

Yagel
<p>Kubernetes doesn't have the same concept of per-application networks.</p>

<p>If you're just using a non-default network to have DNS resolution between containers, you don't really need to do anything.  Make sure you create a <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service</a> for each pod that receives inbound connections, and Kubernetes provides <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">its own DNS system</a> for you.  Instead of Docker-style <code>containername</code> host names, Kubernetes has host names like <code>servicename.namespacename.svc.cluster.local</code>.</p>

<p>If you're trying to partition front-end from back-end services or other things that involve multiple networks, you can set up a <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="nofollow noreferrer">NetworkPolicy</a>.  (I've never felt like I've needed this but understand the motivation.)</p>

<p>If you're manually setting IP addresses or other very-low-level configuration, don't.  Docker can handle this on its own, and you shouldn't be directly using the container IP addresses for anything.  Kubernetes's setup is sufficiently different that this won't translate well anyways.</p>

<p>If you're using <code>--net</code> to have one container use another's network namespace, running the two containers in the same Pod might work for you.  They will be scheduled on the same node and will share a concept of <code>localhost</code>.</p>
