How to detect a docker daemon port

前端 未结 5 365
广开言路
广开言路 2021-01-30 01:48

I have installed Ubuntu and Docker. I am trying to launch Raik container:

$ DOCKER_RIAK_AUTOMATIC_CLUSTERING=1 DOCKER_RAIK_CLUSTER_SIZE=5 DOCKER_RIAK_BACKEND=lev         


        
5条回答
  •  后悔当初
    2021-01-30 02:17

    Since I also had the same problem of "How to detect a docker daemon port" however I had on OSX and after little digging in I found the answer. I thought to share the answer here for people coming from osx.

    If you visit known-issues from docker for mac and github issue, you will find that by default the docker daemon only listens on unix socket /var/run/docker.sock and not on tcp. The default port for docker is 2375 (unencrypted) and 2376(encrypted) communication over tcp(although you can choose any other port).

    On OSX its not straight forward to run the daemon on tcp port. To do this one way is to use socat container to redirect the Docker API exposed on the unix domain socket to the host port on OSX.

    docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 bobrik/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
    

    and then

    export DOCKER_HOST=tcp://localhost:2375
    

    However for local client on mac os you don't need to export DOCKER_HOST variable to test the api.

提交回复
热议问题