You probably heard about Docker by now. Me too. But it took me long to jump on that bandwagon (as a .NET developer). And you probably heard about NoSQL too 🙂
Recently I discoverd RethinkDB
The open-source database for the realtime web
that look really cool and I decided to explore it a little. Since I know myself and I tend to spend ages on setting up on a piece of software (i.e. trial & error approach with heavy help of Google) and in the end it crashes completely I decided to try Docker as well. But … since I am now using Windows 10 and boot2docker using VirtualBox does not work here and VMWare provider for Vagrant is $78 and … stop … end of excuses: I chose CentOS image running in VMPlayer.
So I got CentOS image up and running with docker daemon running, phusion/baseimage-docker
image added (because it is special and fixes some stock Ubuntu 14.04 base image issues).
The base file is
# Use phusion/baseimage as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for
# a list of version numbers.
FROM phusion/baseimage:<VERSION>
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# ...put your own build instructions here...
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Google docker rethinkdb
and the second hit is this GitHub repository. So I took the jessie~2.0.4
(the latest version of course) dockerfile
FROM debian:jessie MAINTAINER Stuart P. Bentley# Add the RethinkDB repository and public key # "RethinkDB Packaging " http://download.rethinkdb.com/apt/pubkey.gpg RUN apt-key adv --keyserver pgp.mit.edu --recv-keys 1614552E5765227AEC39EFCFA7E00EF33A8F2399 RUN echo "deb http://download.rethinkdb.com/apt jessie main" > /etc/apt/sources.list.d/rethinkdb.list ENV RETHINKDB_PACKAGE_VERSION 2.0.4~0jessie RUN apt-get update \ && apt-get install -y rethinkdb=$RETHINKDB_PACKAGE_VERSION \ && rm -rf /var/lib/apt/lists/* VOLUME ["/data"] WORKDIR /data CMD ["rethinkdb", "--bind", "all"] # process cluster webui EXPOSE 28015 29015 8080
and pasted the code into my base docker file, tried to build the image and got error
The following packages have unmet dependencies:
rethinkdb : Depends: libprotobuf9 but it is not installable
Depends: libstdc++6 (>= 4.9) but 4.8.4-2ubuntu1~14.04 is to be installed
E: Unable to correct problems, you have held broken packages.
So I google around and found nothing. Then I decided to try to run database from binaries as described on RethinkDB page
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install rethinkdb
And that worked!
That code in docker file however results in error
/bin/sh: 1: source: not found
which can be easily fixed by running this command in docker file
rm /bin/sh && ln -s /bin/bash /bin/sh
That will install RethinkDB startup service and start it! And the administration UI is accessible at http://localhost:8080
!
During the installation I noticed different version being installed this time – 2.0.4~0trusty
, then I changed RETHINKDB_PACKAGE_VERSION
to 2.0.4~0trusty
and the database installation succeeded (but the service was not started)
invoke-rc.d: policy-rc.d denied execution of start.
Since I am not a Unix expert I just ignored this add added these lines to use the default configuration (I don’t know how to use external file in docker file)
RUN cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
In the end that did not work 🙁 and I went back to the working version (the one with source
). Which did not work either, no connection was made to RethinkDB Administation Console and then it hit me! The container is not running
docker run -d -p 8080:8080 -p 28015:28015 -p 29015:29015 dockerfile
And it worked! 😀
The final version of the dockerfile is here
FROM phusion/baseimage:0.9.17 # fixes 'source: not found' RUN rm /bin/sh && ln -s /bin/bash /bin/sh # Use baseimage-docker's init system. CMD ["/sbin/my_init"] # ...put your own build instructions here... RUN apt-get update RUN apt-get install -y wget # Add the RethinkDB repository and public key RUN apt-key adv --keyserver pgp.mit.edu --recv-keys 1614552E5765227AEC39EFCFA7E00EF33A8F2399 RUN echo "deb http://download.rethinkdb.com/apt trusty main" > /etc/apt/sources.list.d/rethinkdb.list ENV RETHINKDB_PACKAGE_VERSION 2.0.4~0trusty RUN apt-get update \ && sudo apt-get install -y rethinkdb=$RETHINKDB_PACKAGE_VERSION RUN cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf VOLUME ["/data"] WORKDIR /data CMD ["rethinkdb", "--bind", "all"] # process cluster webui EXPOSE 28015 29015 8080 # Clean up APT when done. RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*