content/operate/oss_and_stack/install/install-stack/docker.md
To start the Redis Open Source server using the redis:<version> image, run the following command in your terminal:
{{< highlight bash >}} docker run -d --name redis -p 6379:6379 redis:<version> {{< / highlight >}}
You can then connect to the server using redis-cli, just as you connect to any Redis instance.
If you don’t have redis-cli installed locally, you can run it from the Docker container:
{{< highlight bash >}} $ docker exec -it redis redis-cli {{< / highlight >}}
If you do have redis-cli installed locally, you can run it from your terminal:
{{< highlight bash >}} $ redis-cli -h 127.0.0.1 -p 6379 {{< / highlight >}}
By default, the Redis Docker containers use internal configuration files for Redis. To start Redis with local configuration file, you can do one of the following:
You can create your own Dockerfile that adds a redis.conf from the context into /data/, like so.
FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
Alternatively, you can specify something along the same lines with docker run options.
{{< highlight bash >}} $ docker run -v /myredis/conf:/usr/local/etc/redis --name myredis redis redis-server /usr/local/etc/redis/redis.conf {{< / highlight >}}
where /myredis/conf/ is a local directory containing your redis.conf file. Using this method means that there is no need for you to have a Dockerfile for your redis container.
The mapped directory should be writable, as depending on the configuration and mode of operation, Redis may need to create additional configuration files or rewrite existing ones.
To mount directories or files to your Docker container, specify -v to configure a local volume. This command stores all data in the local directory local-data:
{{< highlight bash >}} $ docker run -v /local-data/:/data --name redis -p 6379:6379 redis:<version> {{< / highlight >}}
See the official Redis page on Docker Hub for more options.