Tuesday, December 30, 2014

Windows+Docker+Redis

Today I've decided to investigate Docker, via doing simple task: installing Redis.

Let's assume that you already familiar with Chocolatey (package manager for Windows), and have installed.

Open powershell with administrative rights and intall Docker:

    choco install docker

After installation PC restart might be required(as in my case). Also, it will install Oracle VirtualBox, which has conflicts with Hyper-V, so probably you will have to uninstall last one.

Now we should start it:

     boot2docker up

Now let's connect to our machine:

    boot2docker ssh -L 6379:localhost:6379

You don't have to specify -L parameter, but we won't to access hour Redis instance from outside container, so we have to do port mapping. First port in paramenters is exposing port of our container(we will use it to connect to Redis). Second is inner host port. For more complex port mapping please check official documentation.

Next step is get Redis image from source:

    docker pull dockerfile/redis

At this point we are ready to start our instance:

    docker run -d --name redis -p 6379:6379 dockerfile/redis 

1st - outter container port (should match 2nd port from ssh command). 2nd - inner container port, this image uses redis default port 6379. More documents about starting redis here.

To stop and remove container execute next commands:

    docker stop redis
    docker rm redis

No comments:

Post a Comment