<p>I know <code>k3d</code> can do this magically via <code>k3d cluster create myname --token MYTOKEN --agents 1</code>, but I am trying to figure out how to do the most simple version of that 'manually'. I want to create a server something like:</p>
<pre><code> docker run -e K3S_TOKEN=MYTOKEN rancher/k3s:latest server
</code></pre>
<p>And connect an agent something like like:</p>
<pre><code> docker run -e K3S_TOKEN=MYTOKEN -e K3S_URL=https://localhost:6443 rancher/k3s:latest agent
</code></pre>
<p>Does anyone know what ports need to be forwarded here? How can I set this up? Nearly everything I try, the agent complains about port 6444 already in use, even if I disable as much as possible about the server with any combination of <code>--no-deploy servicelb --disable-agent --no-deploy traefik</code></p>
<p>Feel free to disable literally everything other than the server and the agent, I'm trying to make this ultra ultra simple, but just butting my head against a wall at the moment. Thanks!</p>

ricky116
<p>The containers must &quot;see&quot; each other. Docker isolates the networks by default, so &quot;localhost&quot; in your agent container is the agent container itself.</p>
<p>Possible solutions:
Run both containers without network isolation using <code>--net=host</code>, map API port of the server to the host with <code>--port</code> and use the host IP in the agent container or use docker-compose.</p>
<p>A working example for docker-compose is described here: <a href="https://www.trion.de/news/2019/08/28/kubernetes-in-docker-mit-k3s.html" rel="nofollow noreferrer">https://www.trion.de/news/2019/08/28/kubernetes-in-docker-mit-k3s.html</a></p>
