Port 2376 (Docker API over TLS)
Key facts
- Port
- 2376
- Protocols
- TCP
- Range
- Registered port, 1024-49151
- IANA service name
- docker-s
IANA assigns ports in this range to services on request, under RFC 6335.
About port 2376
Port 2376 is the port of the Docker API over a TLS-encrypted connection, for managing Docker on a remote server with client certificates. In the IANA port registry, TCP port 2376 is registered for the docker-s service, described as Docker REST API (ssl).
According to the Docker documentation, when you enable network access to Docker with TLS, the conventional port is 2376. With the tlsverify option, the server accepts only clients that present a certificate signed by your certificate authority (CA), so even someone who reaches the port can't send commands without a matching certificate.
What port 2376 is used for
- Remote management: administrators run docker commands from their own computer against a remote server, over an encrypted and authenticated connection.
- CI/CD systems: build servers connect to a remote Docker server to build and run containers.
- Central management tools: tools that manage several Docker servers connect to each server on port 2376.
When there is no need for ongoing network access, a connection over SSH is simpler, because it doesn't require managing certificates.
Port 2376 in the firewall
Even with TLS, allow port 2376 only from the addresses that need to manage Docker:
- UFW:
ufw allow from 203.0.113.10 to any port 2376 proto tcp - firewalld:
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="2376" protocol="tcp" accept'
When you restrict access to specific addresses, also delete any earlier rule that opened the port to everyone, or that general rule will keep allowing access from any address.
Keep port 2375 closed in any case.
Risks and security
The certificates are the keys to the server. According to the Docker documentation, anyone who holds a valid client certificate effectively has root privileges on the server, so protect it like a root password. A few settings keep the connection safe:
- Always enable tlsverify, so that the server accepts only clients with a signed certificate.
- Keep the certificate authority key (ca-key.pem) off the server, in a secure place.
- Give certificates a reasonable validity period, and revoke the certificates of devices no longer in use and of employees who have left.
- Restrict the port in the firewall to known addresses.
Commands to check and configure
-
dockerd --tlsverify --tlscacert=ca.pem --tlscert=server-cert.pem --tlskey=server-key.pem -H=0.0.0.0:2376Starts Docker with TLS on port 2376, accepting only clients with a certificate signed by ca.pem. On a permanent server, set the same options in the /etc/docker/daemon.json file.
-
docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H=host1.example.com:2376 versionConnects to a remote Docker server over TLS and shows its version, to check that the connection and the certificates are valid.
-
export DOCKER_HOST=tcp://host1.example.com:2376 DOCKER_TLS_VERIFY=1Makes all docker commands in the current window connect to the remote server over TLS. By default, the certificates are read from the ~/.docker directory.
-
openssl s_client -connect host1.example.com:2376Connects to port 2376 and shows the server certificate, including the name and the expiry date.
-
ss -tlnp | grep dockerdShows which address and port Docker is listening on (requires root privileges).
-
ufw allow from 203.0.113.10 to any port 2376 proto tcpAllows access to port 2376 only from the specified IP address (UFW).
-
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="2376" protocol="tcp" accept'Allows access to port 2376 in firewalld only from the specified IP address. Then run firewall-cmd --reload.
Port 2376 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 2376 | TCP | docker-s | Docker REST API (ssl) |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 2376 FAQ
When should I use port 2376, and when SSH?
SSH fits most cases: there are no certificates to manage, and the connection uses SSH keys you already have. Port 2376 fits when a management tool or a build server needs a permanent connection to the Docker API over the network.
How do I set up my computer to always connect to the remote server?
Copy ca.pem, cert.pem and key.pem to the ~/.docker directory, and set export DOCKER_HOST=tcp://host1.example.com:2376 DOCKER_TLS_VERIFY=1. From then on, regular docker commands connect to the remote server over TLS.
Why do I get a certificate error when connecting to port 2376?
The common causes are an expired certificate, a client certificate signed by a different certificate authority, or a server name that doesn't appear in the server certificate. Check the certificate with openssl s_client -connect host1.example.com:2376. The OpenSSL commands page has commands for checking certificates.
Where can I find more useful Docker commands?
The Docker commands page collects the commands for managing containers, images and volumes, and the Docker Compose commands page has the commands for managing several services together.