dockerdocker-cli

What are the possible formats of the DOCKER_HOST URLs?


Remote docker servers can be reached by the docker cli by settings the DOCKER_HOST environment variable.

Mostly, tcp://<hostname-or-ip>:<port> or sometimes ssh://<hostname-or-ip>:<port> is used.

Unfortunately, the docker documentation talks about everything, except the possible URL formats of this variable. What are they, how do they work?


Solution

  • The parsing of the DOCKER_HOST variable happens in the parseDockerDaemonHost function in the opts/hosts.go source fragment of the docker-cli.

    The possible values are the following:

    Protocol-less URLs (//host:port) default to tcp://. Any other URL formats are rejected with the Invalid bind address format error message.

    The communication protocol is http(s), although I had some issues with it in proxied configurations.