{
  "schema_version": 2,
  "id": "operate/oss_and_stack/install/install-stack/docker",
  "title": "Run Redis Open Source on Docker",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/docker/",
  "summary": "How to run Redis Open Source using Docker",
  "tags": [
    "docs",
    "operate",
    "stack",
    "oss"
  ],
  "last_updated": "2026-09-21T15:59:08+01:00",
  "page_type": "content",
  "content_hash": "96e5de686318ad53f642095ef3e23905efc33e59e66cd68652b33849a31c606f",
  "sections": [
    {
      "id": "install-docker",
      "title": "Install Docker",
      "role": "setup",
      "text": "Follow the Docker installation instructions for your operating system:\n\n- [Linux](https://docs.docker.com/desktop/setup/install/linux/)\n- [macOS](https://docs.docker.com/docker-for-mac/install/)\n- [Windows](https://store.docker.com/editions/community/docker-ce-desktop-windows)\n\n> [!NOTE]\n> On Windows, make sure Docker is configured to run Linux-based containers."
    },
    {
      "id": "run-redis-open-source-on-docker",
      "title": "Run Redis Open Source on Docker",
      "role": "content",
      "text": "To start the Redis Open Source server using the `redis:<version>` image, run the following command in your terminal:\n\n\ndocker run -d --name redis -p 6379:6379 redis:<version>"
    },
    {
      "id": "connect-with-redis-cli",
      "title": "Connect with redis-cli",
      "role": "content",
      "text": "You can then connect to the server using `redis-cli`, just as you connect to any Redis instance.\n\nIf you don’t have `redis-cli` installed locally, you can run it from the Docker container:\n\n\n$ docker exec -it redis redis-cli\n\n\nIf you want to install `redis-cli` locally, see\n[Install redis-cli](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/install-redis-cli).\n\nIf you already have `redis-cli` installed locally, you can run it from your terminal:\n\n\n$ redis-cli -h 127.0.0.1 -p 6379"
    },
    {
      "id": "use-a-local-configuration-file",
      "title": "Use a local configuration file",
      "role": "content",
      "text": "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:\n\nYou can create your own Dockerfile that adds a `redis.conf` from the context into `/data/`, like so.\n\n[code example]\nAlternatively, you can specify something along the same lines with docker run options.\n\n\n$ docker run -v /myredis/conf:/usr/local/etc/redis --name myredis redis redis-server /usr/local/etc/redis/redis.conf\n\n\nwhere `/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.\n\nThe 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."
    },
    {
      "id": "use-local-storage-for-data-persistence",
      "title": "Use local storage for data persistence",
      "role": "content",
      "text": "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:\n\n\n$ docker run -v /local-data/:/data --name redis -p 6379:6379 redis:<version>\n\n\nSee the [official Redis page on Docker Hub](https://hub.docker.com/_/redis) for more options."
    }
  ],
  "examples": [
    {
      "id": "use-a-local-configuration-file-ex0",
      "language": "plaintext",
      "code": "FROM redis\nCOPY redis.conf /usr/local/etc/redis/redis.conf\nCMD [ \"redis-server\", \"/usr/local/etc/redis/redis.conf\" ]",
      "section_id": "use-a-local-configuration-file"
    }
  ]
}
