Guide
Manage remote Docker hosts behind NAT
Edge sites, home labs and customer networks often can't take an inbound connection. To manage Docker there, the connection has to start from the host. Here are the usual options, and what each costs you.
Updated , for FleetOps v1.4.1.
The options
From the one to avoid to the one that needs nothing open.
1. The Docker API on TCP: avoid
Port 2375 is unauthenticated: anyone who reaches it controls the host as root. Port 2376 with TLS client certificates is better, but it still needs an inbound port, which NAT rules out, and it puts a root-equivalent API on the network.
2. SSH
Docker can talk to a remote daemon over SSH, with no extra software. It needs the host's SSH port to be reachable, so behind NAT you'd need a port forward or a jump host.
docker context create edge-1 --docker host=ssh://admin@edge-1.example.com
docker --context edge-1 ps
3. A VPN or overlay network
WireGuard or a mesh VPN gives the host a private address you can reach, and then SSH works as above. It's a good fit when you already run one; it's a lot to add just to manage containers.
4. An agent that dials out
The host runs a small agent that connects out to your management server and keeps that connection open. Nothing on the host listens, so it works behind NAT, carrier-grade NAT and most firewalls. This is how FleetOps joins remote hosts.
With FleetOps
One server you can reach, an agent on each host.
On the server: start FleetOps with HTTPS, because agents are refused on plain HTTP. Without a certificate of your own, it makes a self-signed one:
docker run -d --name fleetops -p 9000:9000 \
-p 9443:9443 \
-e FLEETOPS_TLS_BIND=0.0.0.0:9443 \
-v fleetops-data:/data \
-v /var/run/docker.sock:/var/run/docker.sock \
--group-add "$(docker run --rm -v /var/run/docker.sock:/s busybox:1.37 stat -c %g /s)" \
fleets/fleetops
For each host: in Admin → Environments → Add environment, choose a remote Docker host. FleetOps shows a docker run command for fleets/fleetops-agent with a join token that works once and expires in 15 minutes. Run it on the host. The agent trades the token for its own key and connects; the host appears in the UI with its containers, logs, terminals, images and stacks.
The agent carries raw streams to the host's Docker socket over one WebSocket, so the socket is never exposed on the network, and every action goes through the same roles and audit log as a local host. Docker Swarms and Kubernetes clusters join the same way. The install guide has every command.
Questions
How do I manage a Docker host that is behind NAT?
Use a connection the host starts itself. A dial-out agent, such as fleetops-agent, connects from the host to the management server over HTTPS, so the host needs no inbound port, port forwarding or public address.
Is it safe to expose the Docker API on TCP port 2375 or 2376?
Port 2375 is unauthenticated and gives root-equivalent control of the host to anyone who reaches it. Port 2376 with TLS client certificates is safer, but it still needs an inbound port and puts a root-equivalent API on the network. An outbound agent or an SSH connection avoids both.
Does the FleetOps agent expose the Docker socket?
No. The socket stays a Unix socket on the host. The agent only copies bytes between it and the FleetOps server over its own authenticated tunnel, and every request goes through the server's role checks and audit log.
What does the remote host need to reach?
Only the FleetOps server's HTTPS port, outbound. Start the server with HTTPS (--tls-bind), because agents are refused on plain HTTP.