How to use redis-cli with Redis on Docker?

3.9k views Asked by At

Run Redis in Docker

File docker-compose.yml

version: "3.8"

services:
  redis:
    image: redis
    volumes:
      - ./data:/data
    ports:
      - 6379:6379
docker pull redis
docker-compose up
docker-compose up -d
docker container ls
telnet localhost 6379

How to connect to Redis server with redis-cli ?

1

There are 1 answers

2
n0nvme On BEST ANSWER

You can run attach to docker container and use redis-cli directly.

This command will attach you to the container's shell

docker exec -it CONTAINER_ID /bin/sh

Then you can use redis-cli just like it installed directly on the host system