mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
incorporate feedback for improving the PR
This commit is contained in:
parent
418ef43fbb
commit
4ab241c930
1 changed files with 44 additions and 25 deletions
|
@ -7,56 +7,75 @@
|
||||||
Create a redis service
|
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
|
Very simple, no frills, redis service.
|
||||||
imported.
|
|
||||||
|
|
||||||
Open a docker container
|
Open a docker container
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
::
|
.. code-block:: bash
|
||||||
|
|
||||||
$ docker run -i -t base /bin/bash
|
docker run -i -t base /bin/bash
|
||||||
|
|
||||||
Building your image
|
Building your image
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Within your docker container. Once installed, <ctl-c> 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 update
|
||||||
$ apt-get install redis-server
|
apt-get install redis-server
|
||||||
SIGINT received
|
exit
|
||||||
|
|
||||||
Snapshot the installation
|
Snapshot the installation
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
::
|
.. code-block:: bash
|
||||||
|
|
||||||
$ docker ps # grab the container id
|
docker ps -a # grab the container id (this will be the last one in the list)
|
||||||
$ docker commit <container_id> <your username>/redis
|
docker commit <container_id> <your username>/redis
|
||||||
|
|
||||||
Run the service
|
Run the service
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Running the service with `-d` runs the container in detached mode, leaving the
|
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 <your username>/redis /usr/bin/redis-server
|
.. code-block:: bash
|
||||||
|
|
||||||
Test
|
docker run -d -p 6379 <your username>/redis /usr/bin/redis-server
|
||||||
----
|
|
||||||
|
|
||||||
::
|
Test 1
|
||||||
|
++++++
|
||||||
|
|
||||||
$ docker ps # grab the new container id
|
Connect to the container with the redis-cli.
|
||||||
$ docker inspect <container_id> # grab the ipaddress
|
|
||||||
$ docker port <container_id> 6379 # grab the external port
|
.. code-block:: bash
|
||||||
$ redis-cli -h <ipaddress> -p <external port>
|
|
||||||
redis 10.0.3.32:49175> set docker awesome
|
docker ps # grab the new container id
|
||||||
|
docker inspect <container_id> # grab the ipaddress of the container
|
||||||
|
redis-cli -h <ipaddress> -p 6379
|
||||||
|
redis 10.0.3.32:6379> set docker awesome
|
||||||
OK
|
OK
|
||||||
redis 10.0.3.32:49175> get docker
|
redis 10.0.3.32:6379> get docker
|
||||||
"awesome"
|
"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 <container_id> 6379 # grab the external port
|
||||||
|
ifconfig # grab the host ip address
|
||||||
|
redis-cli -h <host ipaddress> -p <external port>
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue