github.com/tompao/docker@v1.9.1/docs/examples/running_riak_service.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Dockerizing a Riak service" 4 description = "Build a Docker image with Riak pre-installed" 5 keywords = ["docker, example, package installation, networking, riak"] 6 [menu.main] 7 parent = "smn_apps_servs" 8 +++ 9 <![end-metadata]--> 10 11 # Dockerizing a Riak service 12 13 The goal of this example is to show you how to build a Docker image with 14 Riak pre-installed. 15 16 ## Creating a Dockerfile 17 18 Create an empty file called `Dockerfile`: 19 20 $ touch Dockerfile 21 22 Next, define the parent image you want to use to build your image on top 23 of. We'll use [Ubuntu](https://registry.hub.docker.com/_/ubuntu/) (tag: 24 `trusty`), which is available on [Docker Hub](https://hub.docker.com): 25 26 # Riak 27 # 28 # VERSION 0.1.1 29 30 # Use the Ubuntu base image provided by dotCloud 31 FROM ubuntu:trusty 32 MAINTAINER Hector Castro hector@basho.com 33 34 After that, we install the curl which is used to download the repository setup 35 script and we download the setup script and run it. 36 37 # Install Riak repository before we do apt-get update, so that update happens 38 # in a single step 39 RUN apt-get install -q -y curl && \ 40 curl -sSL https://packagecloud.io/install/repositories/basho/riak/script.deb | sudo bash 41 42 Then we install and setup a few dependencies: 43 44 - `supervisor` is used manage the Riak processes 45 - `riak=2.0.5-1` is the Riak package coded to version 2.0.5 46 47 <!-- --> 48 49 # Install and setup project dependencies 50 RUN apt-get update && \ 51 apt-get install -y supervisor riak=2.0.5-1 52 53 RUN mkdir -p /var/log/supervisor 54 55 RUN locale-gen en_US en_US.UTF-8 56 57 COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 58 59 After that, we modify Riak's configuration: 60 61 # Configure Riak to accept connections from any host 62 RUN sed -i "s|listener.http.internal = 127.0.0.1:8098|listener.http.internal = 0.0.0.0:8098|" /etc/riak/riak.conf 63 RUN sed -i "s|listener.protobuf.internal = 127.0.0.1:8087|listener.protobuf.internal = 0.0.0.0:8087|" /etc/riak/riak.conf 64 65 Then, we expose the Riak Protocol Buffers and HTTP interfaces: 66 67 # Expose Riak Protocol Buffers and HTTP interfaces 68 EXPOSE 8087 8098 69 70 Finally, run `supervisord` so that Riak is started: 71 72 CMD ["/usr/bin/supervisord"] 73 74 ## Create a supervisord configuration file 75 76 Create an empty file called `supervisord.conf`. Make 77 sure it's at the same directory level as your `Dockerfile`: 78 79 touch supervisord.conf 80 81 Populate it with the following program definitions: 82 83 [supervisord] 84 nodaemon=true 85 86 [program:riak] 87 command=bash -c "/usr/sbin/riak console" 88 numprocs=1 89 autostart=true 90 autorestart=true 91 user=riak 92 environment=HOME="/var/lib/riak" 93 stdout_logfile=/var/log/supervisor/%(program_name)s.log 94 stderr_logfile=/var/log/supervisor/%(program_name)s.log 95 96 ## Build the Docker image for Riak 97 98 Now you should be able to build a Docker image for Riak: 99 100 $ docker build -t "<yourname>/riak" . 101 102 ## Next steps 103 104 Riak is a distributed database. Many production deployments consist of 105 [at least five nodes]( 106 http://basho.com/why-your-riak-cluster-should-have-at-least-five-nodes/). 107 See the [docker-riak](https://github.com/hectcastro/docker-riak) project 108 details on how to deploy a Riak cluster using Docker and Pipework.