Riak container does not start when its data volume is mounted

862 views Asked by At

The following command works perfectly and the riak service starts as expected:

docker run --name=riak -d -p 8087:8087 -p 8098:8098 -v $(pwd)/schemas:/etc/riak/schema basho/riak-ts

The local schemas directory is mounted successfully and the sql file in it is read by riak. However if I try to mount the riak's data or log directories, the riak service does not start and timeouts after 15 seconds:

docker run --name=riak -d -p 8087:8087 -p 8098:8098 -v $(pwd)/logs:/var/log/riak -v $(pwd)/schemas:/etc/riak/schema basho/riak-ts

Output of docker logs riak:

+ /usr/sbin/riak start
riak failed to start within 15 seconds,
see the output of 'riak console' for more information.
If you want to wait longer, set the environment variable
WAIT_FOR_ERLANG to the number of seconds to wait.

Why does riak not start when it's logs or data directories are mounted to local directories?

1

There are 1 answers

0
Qasim Sarfraz On BEST ANSWER

This issue is with the directory owner of mounted log folder. The folder $GROUP and $USER are expected to be riak as follow:

root@20e489124b9a:/var/log# ls -l
drwxr-xr-x 2 riak riak   4096 Jul 19 10:00 riak

but with volumes you are getting:

root@3546d261a465:/var/log# ls -l
drwxr-xr-x 2 root root   4096 Jul 19 09:58 riak

One way to solve this is to have the directory ownership as riak user and group on host before starting the container. I looked the UID/GID (/etc/passwd) in docker image and they were:

riak:x:102:105:Riak user,,,:/var/lib/riak:/bin/bash

now change the ownership on host directories before starting the container as:

sudo chown 102:105 logs/
sudo chown 102:105 data/

This should solve it. At least for now. Details here.