github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/docs/sources/examples/running_riak_service.md (about)

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