Last active
August 15, 2024 15:15
-
-
Save dustin/6605182 to your computer and use it in GitHub Desktop.
How I built couchbase 2.2 for docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.