Add documentation for running a redis process with docker
| 20 | 21 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,81 @@ |
| 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 |
+.. include:: example_header.inc |
|
| 10 |
+ |
|
| 11 |
+Very simple, no frills, redis service. |
|
| 12 |
+ |
|
| 13 |
+Open a docker container |
|
| 14 |
+----------------------- |
|
| 15 |
+ |
|
| 16 |
+.. code-block:: bash |
|
| 17 |
+ |
|
| 18 |
+ docker run -i -t base /bin/bash |
|
| 19 |
+ |
|
| 20 |
+Building your image |
|
| 21 |
+------------------- |
|
| 22 |
+ |
|
| 23 |
+Update your docker container, install the redis server. Once installed, exit out of docker. |
|
| 24 |
+ |
|
| 25 |
+.. code-block:: bash |
|
| 26 |
+ |
|
| 27 |
+ apt-get update |
|
| 28 |
+ apt-get install redis-server |
|
| 29 |
+ exit |
|
| 30 |
+ |
|
| 31 |
+Snapshot the installation |
|
| 32 |
+------------------------- |
|
| 33 |
+ |
|
| 34 |
+.. code-block:: bash |
|
| 35 |
+ |
|
| 36 |
+ docker ps -a # grab the container id (this will be the last one in the list) |
|
| 37 |
+ docker commit <container_id> <your username>/redis |
|
| 38 |
+ |
|
| 39 |
+Run the service |
|
| 40 |
+--------------- |
|
| 41 |
+ |
|
| 42 |
+Running the service with `-d` runs the container in detached mode, leaving the |
|
| 43 |
+container running in the background. Use your snapshot. |
|
| 44 |
+ |
|
| 45 |
+.. code-block:: bash |
|
| 46 |
+ |
|
| 47 |
+ docker run -d -p 6379 <your username>/redis /usr/bin/redis-server |
|
| 48 |
+ |
|
| 49 |
+Test 1 |
|
| 50 |
+ |
|
| 51 |
+Connect to the container with the redis-cli. |
|
| 52 |
+ |
|
| 53 |
+.. code-block:: bash |
|
| 54 |
+ |
|
| 55 |
+ docker ps # grab the new container id |
|
| 56 |
+ docker inspect <container_id> # grab the ipaddress of the container |
|
| 57 |
+ redis-cli -h <ipaddress> -p 6379 |
|
| 58 |
+ redis 10.0.3.32:6379> set docker awesome |
|
| 59 |
+ OK |
|
| 60 |
+ redis 10.0.3.32:6379> get docker |
|
| 61 |
+ "awesome" |
|
| 62 |
+ redis 10.0.3.32:6379> exit |
|
| 63 |
+ |
|
| 64 |
+Test 2 |
|
| 65 |
+ |
|
| 66 |
+Connect to the host os with the redis-cli. |
|
| 67 |
+ |
|
| 68 |
+.. code-block:: bash |
|
| 69 |
+ |
|
| 70 |
+ docker ps # grab the new container id |
|
| 71 |
+ docker port <container_id> 6379 # grab the external port |
|
| 72 |
+ ifconfig # grab the host ip address |
|
| 73 |
+ redis-cli -h <host ipaddress> -p <external port> |
|
| 74 |
+ redis 192.168.0.1:49153> set docker awesome |
|
| 75 |
+ OK |
|
| 76 |
+ redis 192.168.0.1:49153> get docker |
|
| 77 |
+ "awesome" |
|
| 78 |
+ redis 192.168.0.1:49153> exit |