Start the boot2docker on Windows host, run the following commands to create a container instance:
> docker run -i -t -p 6379:6379 --name=redis ubuntu bash
Note that the "-p 6379:6379" expose the port 6379 (which is the port on which redis server run by default) of the docker container as the port of the docker vm, so that it can be accessed from the Windows host. In the "redis" container, run the following command to install the necessary tools for building redis:
> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get install build-essential
> sudo apt-get install tk8.5 tcl8.5
> sudo apt-get install wget
In the "redis" container, run the following command to download and build the redis
> cd /opt
> wget http://download.redis.io/redis-stable.tar.gz
> tar xvzf redis-stable.tar.gz
> cd redis-stable
> make distclean
> make test
In the "redis" container, run the following command to start running the redis server:
> cd /opt/redis-stable/src
> ./redis-server
Open a console windows on the Windows host and type the following command to find out the boot2docker ip address:
> boot2docker ip
which should return something like 192.168.59.103 (Note that the address 192.169.59.103 is the ip address of the docker vm, which by default the docker container is mapped to)
Now start a redis client from the Windows console windows (if you have not downloaded the redis client binary, can download it from https://github.com/ServiceStack/redis-windows) by entering the following command line in the console of the Windows host:
> cd [your-redis-windows-binary-directory]
> redis-cli.exe -h 192.168.59.103
That's it. This is the link to some C# demo code (using the ServiceStack.Redis library via nuget) which connect to the redis server running in the docker container:
https://dl.dropboxusercontent.com/u/113201788/Redis/RedisDemoCSharp.zip
No comments:
Post a Comment