-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create bucket during build of the container? #27
Comments
You need to configure your server before any buckets can be created. https://github.com/arun-gupta/docker-images/blob/master/couchbase/Dockerfile shows how to configure the Couchbase server and load |
Thank you. It works! But I have one more question. Any suggestion how to solve this issue? |
What is the exact command you are using? |
I use this command: Password is correct (I changed it in configure-cluster.sh). I also created cluster via REST API because even when was my server configured I couldn't run command from my first comment in this topic - server was still returning connection refused. Could be this problem caused by user rights or permissions? I'm running Docker on Windows and I have read that it can cause some issues. |
I've never personally tried Docker on Windows. Are you using Docker Machine on Windows? |
Yes, I'm. I will try to install docker on virtual machine with linux and see what happens. |
Ok, so I have tried to run my Dockerfile under Linux and there is the same issue. |
It seems I have found a solution. |
This sounds like a networking issue. Where are you running this command? Inside or outside the docker container? If you are running it from outside, you'll either need to expose some ports or spawn the container with |
Oh, sorry, n/m, I didn't read this carefully enough.
Yeah that won't work because there's no couchbase server process running while the docker image is being built, and I'd advise against trying to pre-bake buckets at build-time, it feels wrong to me. I haven't done much with docker compose yet, but if you can setup container dependencies, you could do something like this: Spin up the following containers:
couchbase-setup would only start after couchbase-server has been launched, and it would be able to access it via a hostname or ip address (say, via docker networking), and then it would issue the Caveat: the |
Interesting thread. I'd suggest the couchbase-setup container should probably poll for the server being up since the startup delay can be pretty variable. Also, Traun, any clever thoughts for how that setup would work the second time you start it up? couchbase-setup would have to know not to try doing any configuration and just exit. Perhaps there's an opportunity here for a little Couchbase helper container here to encapsulate that logic... |
@tleyden Thank you for the explanation and your suggestions. I think that I could do that this way but as @ceejatec said, I would need to check if is my server already set up because I don't want to rewrite user data when I run my application for the second time. I think that I will have to run commands in shell script and check if bucket already exists (for example). If so I can quit the script and don't setup server. What do you think? |
Did anyone make progress on this since the last comment? I've just done the same thing using a similar approach to @arun-gupta above, with https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh to wait for start and basing first-time init on the existence of the couchbase data directory before starting the server. I'd be interested in contributing something back. |
Hi,
is it possible to configure couchbase inside a container?
I have docker-compose.yml with definition of our cloud (several apps in java, redis, dynamodb, ...).
I would need to configure couchbase db during build of the container because application in another container requires it configured to run.
I have tried to put inside my dockerfile something like this:
FROM couchbase/server:latest
RUN /opt/couchbase/bin/couchbase-cli bucket-create -c localhost -u Administrator -p administrator --bucket=default --bucket-type=couchbase --bucket-ramsize=128 --bucket-replica=1 --wait
But whatewer host i put into -c parameter (localhost, container IP, container ID), I always get [Errno 111] Connection refused. I tried to restart couchbase service before this command and sleep for 10 seconds but nothing helps.
I know that I can use docker exec from outside the container to create bucket (that works fine for me), but I would really like to run whole cloud by just "docker-compose up" command.
Am I missing something? Is there a way how to make this work?
The text was updated successfully, but these errors were encountered: