Docker - setting host directory causes couchbase container to fail


#1

Hi,

I’m using boot2docker on my mac and I’m trying to mount a directory for couchbase data volume using the following command:

run -d -v ~/couchbase:/opt/couchbase/var -p 8091:8091 --name my-couchbase couchbase

But when I checked the logs, I got this:

Starting Couchbase Server -- Web UI available at http://<ip>:8091
{"init terminating in do_boot",{{badmatch,{error,{bad_return,{{ns_babysitter,start,[normal,[]]},{'EXIT',{shutdown,{gen_server,call,[ale,{set_loglevel,error_logger,debug}]}}}}}}},[{init,start_it,1,[]},{init,start_em,1,[]}]}}
init terminating in do_boot ()

If I create a new container without setting -v, it’s able to start with no issues.

Any ideas on how to resolve this?


#2

Can you find the couchbase error log in /opt/couchvar/var/lib/logs/error.log and upload into a github gist?

That should give more detailed information.

Also:

  • Does the ~/couchbase directory exist?
  • Is it empty?

#3

How can I get to error.log when I can’t get the container to run?

Regarding “~/couchbase”, it does exist and has the following folder structure:

couchbase
  lib
    couchbase
      config
      data
      logs
      stats
    moxi

But all the folders are empty.


#4

I had the same issue.
The problem is VBOX (or boot2docker image, I can’t tell) doesn’t have the right to edit the ~/couhbase folder

I solved the problem by changing the rights of the ~/couchbase to “everyone: Read & Write” when getting information of the folder (Command+i):

and you need to select on the bottom parameters “Apply to enclosed items”.

I hope it will works also on your machine.


#5

The problem is I can’t access to the UI interface:

(I have tested also with latest enterprise couchbase version, it’s not releated to couchbase beta)

Same issue when I try to access to the Couchbase image directly from the boot2docker VM via ssh:

For a simple test, I have tested NGINX on boot2docker to see if my configuration is wrong, Nginx port forwrding works well:


#6

Thanks for your suggesiton Val_Entin2. By changing the folder permission, I’m able to get the container to not crash on startup. But I’m encountering another problem. The container has the following log output:

Starting Couchbase Server -- Web UI available at http://<ip>:8091
{"init terminating in do_boot",{{badmatch,{error,{bad_return,{{ns_babysitter,start,[normal,[]]},{'EXIT',{shutdown,{gen_server,call,[ale,{add_sink,ns_server,babysitter_sink,debug}]}}}}}}},[{init,start_it,1,[]},{init,start_em,1,[]}]}}

And I see there are two files created in a couchbase sub-folder:

  • erl_crash.dump.1434431000.1.babysitter - looks like a stacktrace dump
  • babysitter.log - an empty file

#7

Yes I had the same again what I did is,

  • $ cd ~/couchbase
  • $ chmod 777 * or $ chmod 777 -R .
  • Retry to run the couchbase server

It should work if I remember well.


#8

I tried both commands:

  • chmod 777 *
  • “chmod -R 777 couchbase” from parent folder

It resulted in this in the logs:

Starting Couchbase Server -- Web UI available at http://<ip>:8091
{error_logger,{{2015,6,16},{18,20,30}},std_error,"File operation error: eacces. Target: /etc/resolv.conf. Function: get_file. Process: kernel_sup."}

#9

Hi Traun,

Can you add any more suggestions here? I can’t believe that me and Val_Entin2 are the only ones who’s trying to get couchbase to run in boot2docker with a custom volume mount.


#10

My soltuion ATM is to mount the volume on the boot2docker root:

run -d -v /couchbase:/opt/couchbase/var -p 8091:8091 --name my-couchbase couchbase

Which set up the couchbase folder at the root of the boot2docker VM, this works well, but you don’t have access to the data on your host, only if you SSH the boot2docker VM:

$ boot2docker ssh
# cd /couchbase

So if you do it this way, each time you start the boot2docker VM, your files will normally be there.
But if, for some reason, you delete the boot2docker image you also delete your couchbase configuration files and your couchbase datas datas.

I think you can do some backups with SSH to your Host if you want to keep your configuration and push them again if you have deleted/upgraded your boot2docker VM.

I think the problem it self come from the way boot2docker have been designed wich mount aiutomatically the /Users forlder on the on the VM. I think it was more for read files from the Host instead to write them.

An other approach would be to use Vagrant your own Linux VM and set up your own volumes instead of Boot2Docker.
But I don’t know if you will came accross the same permission issues.


#11

PS: I have exaclty the same problem for elasticsearch when I try to mount the data folder…
Unable to write…

The problem seems definitely come from boot2docker permission to write files on the disk recursively in folders.


#12

Val_Entin2,

Have you tried using the NFS approach, http://chiefy.github.io/2015/02/24/up-and-running-w-boot2docker-fig-packer.html?


#13

Hi agillette,

Yes, I have done the nfs approach:
configurate nfs on my Host machine
unmount \Users on the vm,
mount \Users[username] with nfs
etc…

And still having after all this mess a new error on couchbase data folder and subfolders:

chown: changing ownership of `var/lib/couchbase/config': Operation not permitted

and the same message on all couchbase data subfolders

This error occurs because couchase is installed on the linux machine under a specific user and this user doesnt have any right on the Host machine (cf same problem on boot2docker with postgre, mysql, apache…)

I tried to do a chown -R 999:999 . and many command to open the rights on the folder to change ownership on the couchbase data folder, but no sucessfull results.

For me the only solutions ATM are:

  • Store Datas on the boot2docker VM and try to make some backup services before updating the boot2docker VM
  • Use vagrant VM instead of docker images with devops like Puppet, Chief or whatever…
  • The old way by installing couchbase on the machine and waiting for Docker team to solve the permission issue (I have choose that one)
  • Develop on linux instead of OSX

I have already spent 2 day trying to solve the problem (to much time for a dev environment), I hope it’s not for nothing, but I need to get back on code and may be try it again @ home this weekend.


#14

I’m going to follow the same tactic and install couchbase locally.