From 5cd0f30a95820be1279a7bdf9b1decd4c06d2fb1 Mon Sep 17 00:00:00 2001 From: John Costa Date: Tue, 9 Apr 2013 11:04:14 -0400 Subject: [PATCH 1/2] add documentation for running a redis process with docker Upstream-commit: 8f15c423e6049507908ec6e7b139f8bccbd6d3ba Component: engine --- .../engine/docs/sources/examples/index.rst | 1 + .../examples/running_redis_service.rst | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 components/engine/docs/sources/examples/running_redis_service.rst diff --git a/components/engine/docs/sources/examples/index.rst b/components/engine/docs/sources/examples/index.rst index 0ab2143a30..e01f662002 100644 --- a/components/engine/docs/sources/examples/index.rst +++ b/components/engine/docs/sources/examples/index.rst @@ -15,4 +15,5 @@ Contents: hello_world hello_world_daemon python_web_app + running_redis_service running_ssh_service diff --git a/components/engine/docs/sources/examples/running_redis_service.rst b/components/engine/docs/sources/examples/running_redis_service.rst new file mode 100644 index 0000000000..a0fc0dd916 --- /dev/null +++ b/components/engine/docs/sources/examples/running_redis_service.rst @@ -0,0 +1,62 @@ +: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 +====================== + +Very simple, no frills, redis service. + +This example assumes you have Docker installed and the base image already +imported. + +Open a docker container +----------------------- + +:: + + $ docker run -i -t base /bin/bash + +Building your image +------------------- + +Within your docker container. Once installed, out of docker. + +:: + + $ apt-get update + $ apt-get install redis-server + SIGINT received + +Snapshot the installation +------------------------- + +:: + + $ docker ps # grab the container id + $ docker commit /redis + +Run the service +--------------- + +Running the service with `-d` runs the container in detached mode, leaving the +container running in the background. +:: + + $ docker run -d -p 6379 -i -t /redis /usr/bin/redis-server + +Test +---- + +:: + + $ docker ps # grab the new container id + $ docker inspect # grab the ipaddress + $ docker port 6379 # grab the external port + $ redis-cli -h -p + redis 10.0.3.32:49175> set docker awesome + OK + redis 10.0.3.32:49175> get docker + "awesome" From aa4c6e3497a7c191597963718a85eb89e78d8e75 Mon Sep 17 00:00:00 2001 From: John Costa Date: Tue, 9 Apr 2013 17:50:12 -0400 Subject: [PATCH 2/2] incorporate feedback for improving the PR Upstream-commit: 4ab241c93080d8df6db4fd0c31b0c26008118422 Component: engine --- .../examples/running_redis_service.rst | 69 ++++++++++++------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/components/engine/docs/sources/examples/running_redis_service.rst b/components/engine/docs/sources/examples/running_redis_service.rst index a0fc0dd916..018b061707 100644 --- a/components/engine/docs/sources/examples/running_redis_service.rst +++ b/components/engine/docs/sources/examples/running_redis_service.rst @@ -7,56 +7,75 @@ Create a redis service ====================== -Very simple, no frills, redis service. +.. include:: example_header.inc -This example assumes you have Docker installed and the base image already -imported. +Very simple, no frills, redis service. Open a docker container ----------------------- -:: +.. code-block:: bash - $ docker run -i -t base /bin/bash + docker run -i -t base /bin/bash Building your image ------------------- -Within your docker container. Once installed, out of docker. +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 - SIGINT received + apt-get update + apt-get install redis-server + exit Snapshot the installation ------------------------- -:: +.. code-block:: bash - $ docker ps # grab the container id - $ docker commit /redis + 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. -:: +container running in the background. Use your snapshot. - $ docker run -d -p 6379 -i -t /redis /usr/bin/redis-server +.. code-block:: bash -Test ----- + docker run -d -p 6379 /redis /usr/bin/redis-server -:: +Test 1 +++++++ - $ docker ps # grab the new container id - $ docker inspect # grab the ipaddress - $ docker port 6379 # grab the external port - $ redis-cli -h -p - redis 10.0.3.32:49175> set docker awesome +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:49175> get docker + 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