github.com/jogo/docker@v1.7.0-rc1/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:
    60  
    61      # Expose Riak Protocol Buffers and HTTP interfaces
    62      EXPOSE 8087 8098
    63  
    64  Finally, run `supervisord` so that Riak is started:
    65  
    66      CMD ["/usr/bin/supervisord"]
    67  
    68  ## Create a supervisord configuration file
    69  
    70  Create an empty file called `supervisord.conf`. Make
    71  sure it's at the same directory level as your `Dockerfile`:
    72  
    73      touch supervisord.conf
    74  
    75  Populate it with the following program definitions:
    76  
    77      [supervisord]
    78      nodaemon=true
    79      
    80      [program:riak]
    81      command=bash -c "/usr/sbin/riak console"
    82      numprocs=1
    83      autostart=true
    84      autorestart=true
    85      user=riak
    86      environment=HOME="/var/lib/riak"
    87      stdout_logfile=/var/log/supervisor/%(program_name)s.log
    88      stderr_logfile=/var/log/supervisor/%(program_name)s.log
    89  
    90  ## Build the Docker image for Riak
    91  
    92  Now you should be able to build a Docker image for Riak:
    93  
    94      $ docker build -t "<yourname>/riak" .
    95  
    96  ## Next steps
    97  
    98  Riak is a distributed database. Many production deployments consist of
    99  [at least five nodes](
   100  http://basho.com/why-your-riak-cluster-should-have-at-least-five-nodes/).
   101  See the [docker-riak](https://github.com/hectcastro/docker-riak) project
   102  details on how to deploy a Riak cluster using Docker and Pipework.