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=leveldb make start-cluster ./bin/start
and get the error message:
It looks like the environment variable DOCKER_HOST has not been set. The Riak cluster cannot be started unless this has been set appropriately. For example:
export DOCKER_HOST="tcp://127.0.0.1:2375"
If I set
export DOCKER_HOST="tcp://127.0.0.1:2375"
all my other containers stop working and said, that can not find the Docker daemon.
It looks like my Docker damon use other than 2375 port. How can I check it ?
Try add
-H tcp://0.0.0.0:2375
(at end ofExecstart
line) instead of-H 0.0.0.0:2375
./etc/systemd/system/docker.service.d/docker.conf
. Inside the filedocker.conf
, paste below content:Restart Docker. After saving this file, reload the configuration by
systemctl daemon-reload
and restart Docker bysystemctl restart docker.service
.Check your Docker daemon. After restarting docker service, you can see the port in the output of
systemctl status docker.service
like/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
.Hope this may help
Thank you!
By default, the docker daemon will use the unix socket
unix:///var/run/docker.sock
(you can check this is the case for you by doing asudo netstat -tunlp
and note that there is no docker daemon process listening on any ports). It's recommended to keep this setting for security reasons but it sounds like Riak requires the daemon to be running on a TCP socket.To start the docker daemon with a TCP socket that anybody can connect to, use the
-H
option:Warning: This means machines that can talk to the daemon through that TCP socket can get root access to your host machine.
Related docs:
http://basho.com/posts/technical/running-riak-in-docker/
https://docs.docker.com/install/linux/linux-postinstall/#configure-where-the-docker-daemon-listens-for-connections
Reference docs of docker: https://docs.docker.com/install/linux/linux-postinstall/#configure-where-the-docker-daemon-listens-for-connections
There are 2 ways in configuring the docker daemon port
1) Configuring at /etc/default/docker file:
2) Configuring at /etc/docker/daemon.json:
If the docker default socket is not configured Docker will wait for infinite period.i.e
NOTE : BUT DON'T CONFIGURE IN BOTH THE CONFIGURATION FILES, the following error may occur :
The reason for adding both the user port[ tcp://127.0.0.1:5000] and default docker socket[unix:///var/run/docker.sock] is that the user port enables the access to the docker APIs whereas the default socket enables the CLI. In case the default port[unix:///var/run/docker.sock] is not mentioned in /etc/default/docker file the following error may occur:
This error is not because that the docker is not running, but because of default docker socket is not enabled.
Once the configuration is enabled restart the docker service and verify the docker port is enabled or not:
Applicable for Docker Version 17.04, may vary with different versions of docker.
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.and then
However for local client on mac os you don't need to export DOCKER_HOST variable to test the api.