Browse code

add documentation for running a redis process with docker

John Costa authored on 2013/04/10 00:04:14
Showing 2 changed files
... ...
@@ -15,4 +15,5 @@ Contents:
15 15
    hello_world
16 16
    hello_world_daemon
17 17
    python_web_app
18
+   running_redis_service
18 19
    running_ssh_service
19 20
new file mode 100644
... ...
@@ -0,0 +1,62 @@
0
+:title: Running a Redis service
1
+:description: Installing and running an redis service
2
+:keywords: docker, example, package installation, networking, redis
3
+
4
+.. _running_redis_service:
5
+
6
+Create a redis service
7
+======================
8
+
9
+Very simple, no frills, redis service.
10
+
11
+This example assumes you have Docker installed and the base image already
12
+imported.
13
+
14
+Open a docker container
15
+-----------------------
16
+
17
+::
18
+
19
+    $ docker run -i -t base /bin/bash
20
+
21
+Building your image
22
+-------------------
23
+
24
+Within your docker container.  Once installed, <ctl-c> out of docker.
25
+
26
+::
27
+
28
+    $ apt-get update
29
+    $ apt-get install redis-server
30
+    SIGINT received
31
+
32
+Snapshot the installation
33
+-------------------------
34
+
35
+::
36
+
37
+    $ docker ps   # grab the container id
38
+    $ docker commit <container_id> <your username>/redis
39
+
40
+Run the service
41
+---------------
42
+
43
+Running the service with `-d` runs the container in detached mode, leaving the
44
+container running in the background.
45
+::
46
+
47
+    $ docker run -d -p 6379 -i -t <your username>/redis /usr/bin/redis-server
48
+
49
+Test
50
+----
51
+
52
+::
53
+
54
+    $ docker ps  # grab the new container id
55
+    $ docker inspect <container_id>    # grab the ipaddress
56
+    $ docker port <container_id> 6379  # grab the external port
57
+    $ redis-cli -h <ipaddress> -p <external port>
58
+    redis 10.0.3.32:49175> set docker awesome
59
+    OK
60
+    redis 10.0.3.32:49175> get docker
61
+    "awesome"