github.com/eikeon/docker@v1.5.0-rc4/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  `latest`), which is available on [Docker Hub](https://hub.docker.com):
    19  
    20      # Riak
    21      #
    22      # VERSION       0.1.0
    23  
    24      # Use the Ubuntu base image provided by dotCloud
    25      FROM ubuntu:latest
    26      MAINTAINER Hector Castro hector@basho.com
    27  
    28  After that, we install and setup a few dependencies:
    29  
    30   - `curl` is used to download Basho's APT
    31      repository key
    32   - `lsb-release` helps us derive the Ubuntu release
    33      codename
    34   - `openssh-server` allows us to login to
    35      containers remotely and join Riak nodes to form a cluster
    36   - `supervisor` is used manage the OpenSSH and Riak
    37      processes
    38  
    39  <!-- -->
    40  
    41      # Install and setup project dependencies
    42      RUN apt-get update && apt-get install -y curl lsb-release supervisor openssh-server
    43  
    44      RUN mkdir -p /var/run/sshd
    45      RUN mkdir -p /var/log/supervisor
    46  
    47      RUN locale-gen en_US en_US.UTF-8
    48  
    49      COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
    50  
    51      RUN echo 'root:basho' | chpasswd
    52  
    53  Next, we add Basho's APT repository:
    54  
    55      RUN curl -sSL http://apt.basho.com/gpg/basho.apt.key | apt-key add --
    56      RUN echo "deb http://apt.basho.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/basho.list
    57  
    58  After that, we install Riak and alter a few defaults:
    59  
    60      # Install Riak and prepare it to run
    61      RUN apt-get update && apt-get install -y riak
    62      RUN sed -i.bak 's/127.0.0.1/0.0.0.0/' /etc/riak/app.config
    63      RUN echo "ulimit -n 4096" >> /etc/default/riak
    64  
    65  Then, we expose the Riak Protocol Buffers and HTTP interfaces, along
    66  with SSH:
    67  
    68      # Expose Riak Protocol Buffers and HTTP interfaces, along with SSH
    69      EXPOSE 8087 8098 22
    70  
    71  Finally, run `supervisord` so that Riak and OpenSSH
    72  are started:
    73  
    74      CMD ["/usr/bin/supervisord"]
    75  
    76  ## Create a supervisord configuration file
    77  
    78  Create an empty file called `supervisord.conf`. Make
    79  sure it's at the same directory level as your `Dockerfile`:
    80  
    81      touch supervisord.conf
    82  
    83  Populate it with the following program definitions:
    84  
    85      [supervisord]
    86      nodaemon=true
    87  
    88      [program:sshd]
    89      command=/usr/sbin/sshd -D
    90      stdout_logfile=/var/log/supervisor/%(program_name)s.log
    91      stderr_logfile=/var/log/supervisor/%(program_name)s.log
    92      autorestart=true
    93  
    94      [program:riak]
    95      command=bash -c ". /etc/default/riak && /usr/sbin/riak console"
    96      pidfile=/var/log/riak/riak.pid
    97      stdout_logfile=/var/log/supervisor/%(program_name)s.log
    98      stderr_logfile=/var/log/supervisor/%(program_name)s.log
    99  
   100  ## Build the Docker image for Riak
   101  
   102  Now you should be able to build a Docker image for Riak:
   103  
   104      $ sudo docker build -t "<yourname>/riak" .
   105  
   106  ## Next steps
   107  
   108  Riak is a distributed database. Many production deployments consist of
   109  [at least five nodes](
   110  http://basho.com/why-your-riak-cluster-should-have-at-least-five-nodes/).
   111  See the [docker-riak](https://github.com/hectcastro/docker-riak) project
   112  details on how to deploy a Riak cluster using Docker and Pipework.