running_redis_service.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. :title: Running a Redis service
  2. :description: Installing and running an redis service
  3. :keywords: docker, example, package installation, networking, redis
  4. .. _running_redis_service:
  5. Create a redis service
  6. ======================
  7. Very simple, no frills, redis service.
  8. This example assumes you have Docker installed and the base image already
  9. imported.
  10. Open a docker container
  11. -----------------------
  12. ::
  13. $ docker run -i -t base /bin/bash
  14. Building your image
  15. -------------------
  16. Within your docker container. Once installed, <ctl-c> out of docker.
  17. ::
  18. $ apt-get update
  19. $ apt-get install redis-server
  20. SIGINT received
  21. Snapshot the installation
  22. -------------------------
  23. ::
  24. $ docker ps # grab the container id
  25. $ docker commit <container_id> <your username>/redis
  26. Run the service
  27. ---------------
  28. Running the service with `-d` runs the container in detached mode, leaving the
  29. container running in the background.
  30. ::
  31. $ docker run -d -p 6379 -i -t <your username>/redis /usr/bin/redis-server
  32. Test
  33. ----
  34. ::
  35. $ docker ps # grab the new container id
  36. $ docker inspect <container_id> # grab the ipaddress
  37. $ docker port <container_id> 6379 # grab the external port
  38. $ redis-cli -h <ipaddress> -p <external port>
  39. redis 10.0.3.32:49175> set docker awesome
  40. OK
  41. redis 10.0.3.32:49175> get docker
  42. "awesome"