diff --git a/docs/sources/examples/index.rst b/docs/sources/examples/index.rst index 5c70ff4926..6a616ec8ff 100644 --- a/docs/sources/examples/index.rst +++ b/docs/sources/examples/index.rst @@ -16,4 +16,5 @@ Contents: hello_world hello_world_daemon python_web_app + running_redis_service running_ssh_service diff --git a/docs/sources/examples/running_redis_service.rst b/docs/sources/examples/running_redis_service.rst new file mode 100644 index 0000000000..018b061707 --- /dev/null +++ b/docs/sources/examples/running_redis_service.rst @@ -0,0 +1,81 @@ +:title: Running a Redis service +:description: Installing and running an redis service +:keywords: docker, example, package installation, networking, redis + +.. _running_redis_service: + +Create a redis service +====================== + +.. include:: example_header.inc + +Very simple, no frills, redis service. + +Open a docker container +----------------------- + +.. code-block:: bash + + docker run -i -t base /bin/bash + +Building your image +------------------- + +Update your docker container, install the redis server. Once installed, exit out of docker. + +.. code-block:: bash + + apt-get update + apt-get install redis-server + exit + +Snapshot the installation +------------------------- + +.. code-block:: bash + + docker ps -a # grab the container id (this will be the last one in the list) + docker commit /redis + +Run the service +--------------- + +Running the service with `-d` runs the container in detached mode, leaving the +container running in the background. Use your snapshot. + +.. code-block:: bash + + docker run -d -p 6379 /redis /usr/bin/redis-server + +Test 1 +++++++ + +Connect to the container with the redis-cli. + +.. code-block:: bash + + docker ps # grab the new container id + docker inspect # grab the ipaddress of the container + redis-cli -h -p 6379 + redis 10.0.3.32:6379> set docker awesome + OK + redis 10.0.3.32:6379> get docker + "awesome" + redis 10.0.3.32:6379> exit + +Test 2 +++++++ + +Connect to the host os with the redis-cli. + +.. code-block:: bash + + docker ps # grab the new container id + docker port 6379 # grab the external port + ifconfig # grab the host ip address + redis-cli -h -p + redis 192.168.0.1:49153> set docker awesome + OK + redis 192.168.0.1:49153> get docker + "awesome" + redis 192.168.0.1:49153> exit