title: | Running a Redis service |
---|---|
description: | Installing and running an redis service |
keywords: | docker, example, package installation, networking, redis |
Very simple, no frills, redis service.
docker run -i -t base /bin/bash
Update your docker container, install the redis server. Once installed, exit out of docker.
apt-get update
apt-get install redis-server
exit
docker ps -a # grab the container id (this will be the last one in the list)
docker commit <container_id> <your username>/redis
Running the service with -d runs the container in detached mode, leaving the container running in the background. Use your snapshot.
docker run -d -p 6379 <your username>/redis /usr/bin/redis-server
Connect to the container with the redis-cli.
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
redis 10.0.3.32:6379> get docker
"awesome"
redis 10.0.3.32:6379> exit
Connect to the host os with the redis-cli.
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