-
-
Save dustin/6605182 to your computer and use it in GitHub Desktop.
#!/bin/sh | |
int=`ip route | awk '/^default/ { print $5 }'` | |
addr=`ip route | egrep "^[0-9].*$int" | awk '{ print $9 }'` | |
mkdir -p /home/core/data/couchbase | |
sudo chown 999:999 /home/core/data/couchbase | |
exec sudo docker run -i -d -t -e DOCKER_EXT_ADDR=$addr \ | |
-v /home/core/data/couchbase:/opt/couchbase/var \ | |
-p 11210:11210 -p 8091:7081 -p 8092:8092 \ | |
dustin/couchbase |
#!/bin/sh | |
untilsuccessful() { | |
"$@" | |
while [ $? -ne 0 ] | |
do | |
echo Retrying... | |
sleep 1 | |
"$@" | |
done | |
} | |
cd /opt/couchbase | |
mkdir -p var/lib/couchbase var/lib/couchbase/config var/lib/couchbase/data \ | |
var/lib/couchbase/stats var/lib/couchbase/logs var/lib/moxi | |
chown -R couchbase:couchbase var | |
/etc/init.d/couchbase-server start | |
int=`ip route | awk '/^default/ { print $5 }'` | |
addr=`ip route | egrep "^[0-9].*$int" | awk '{ print $9 }'` | |
if [ -z "$DOCKER_EXT_ADDR" ] | |
then | |
DOCKER_EXT_ADDR="$addr" | |
fi | |
if [ -n "$ALPHA_PORT_7081_TCP_ADDR" ] | |
then | |
echo "Joining cluster at $ALPHA_PORT_7081_TCP_ADDR" | |
untilsuccessful /opt/couchbase/bin/couchbase-cli server-add -c $ALPHA_PORT_7081_TCP_ADDR:8091 \ | |
--user=Administrator --password=password --server-add=$addr:8091 | |
else | |
echo "Starting cluster" | |
untilsuccessful /opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1:8091 \ | |
--cluster-init-username=Administrator --cluster-init-password=password \ | |
--cluster-init-ramsize=512 | |
untilsuccessful /opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 \ | |
-u Administrator -p password --bucket=default -c localhost:8091 \ | |
--bucket-ramsize=128 | |
fi | |
echo "{\"$addr\": \"$DOCKER_EXT_ADDR\", \"127.0.0.1\": \"$DOCKER_EXT_ADDR\"}" > /tmp/confsed.json | |
exec /usr/local/sbin/confsed -rewriteconf /tmp/confsed.json http://localhost:8091/ |
FROM ubuntu | |
MAINTAINER Dustin Sallings "[email protected]" | |
ADD http://cbfs-ext.hq.couchbase.com/couchbase-dist/couchbase-server-enterprise_2.2.0_x86_64.deb /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb | |
RUN apt-get update | |
RUN apt-get install -y librtmp0 python-httplib2 | |
RUN dpkg -i /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb | |
RUN rm /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb | |
RUN /etc/init.d/couchbase-server stop | |
RUN rm -r /opt/couchbase/var/lib | |
ADD http://cbfs-ext.hq.couchbase.com/dustin/software/confsed/confsed.lin64.gz /usr/local/sbin/confsed.gz | |
RUN gzip -d /usr/local/sbin/confsed.gz | |
RUN chmod 755 /usr/local/sbin/confsed | |
ADD http://cbfs-ext.hq.couchbase.com/dustin/software/docker/cb/couchbase-script /usr/local/sbin/couchbase | |
RUN chmod 755 /usr/local/sbin/couchbase | |
# 7081 is 8091 with rewrites | |
EXPOSE 7081 8092 11210 | |
CMD /usr/local/sbin/couchbase |
Well, apparently I get comments here. I had no idea. sigh
I don't actually know why it would say there's no command specified. There's clearly one in the Dockerfile. :/ I did confirm it happens with the published image, though. I'll fix this.
fwiw, i was able to get that working by first doing:
sudo docker pull dustin/couchbase
and then use the id it gives (get using sudo docker images) instead of using dustin/couchbase in the run command.
There was some confusion between :2.2
and :latest
. I think it's all sorted now.
Thank you Dustin for this example. I would also recommend an rebalance after add server (untilsuccessful /opt/couchbase/bin/couchbase-cli server-add -c $ALPHA_PORT_7081_TCP_ADDR:8091
--user=Administrator --password=password --server-add=$addr:8091)
Hi! When I try to start this docker image using the commands you listed on the docker registry:
mkdir -p /home/core/data/couchbase
sudo chown 999:999 /home/core/data/couchbase
sudo docker run -i -d -t -v /home/core/data/couchbase:/opt/couchbase/var -p 11210:11210 -p 8091:7081 -p 8092:8092 dustin/couchbase
I get the error "Error: No command specified". If I append a /bin/bash or something to that effect to the end, I don't get the error, but the docker image doesn't appear to keep running either.