Search code examples
dockeruridocker-java

How to get the docker host URI on my localhost


Is there a command that I can evaluate (eval $COMMAND) or an environment variable that I can inspect to get the URI of the locally running docker host? I need to be this an expression to evaluate at runtime, since I need to use it in a script intended to run on hosts where docker engine may not be running on the standard ports.

Thanks.


Solution

  • I am not sure I have fully understood your question but hopefully this may shed some light.

    The docker command is just a REST client. By default the client connects to the unix-socket /var/run/docker.sock to send requests to the docker daemon. You can practically achieve the same thing by running curl:

    curl --unix-socket /var/run/docker.sock http:/localhost/version
    

    Now if your docker daemon was configured for remote access, you probably have the URI information in the docker.service service file. See this post How do I find the Docker REST API URL?.

    Hope that helps