# Create a network for a Redis
docker network create redisnet
# Run a single instance that is automatically removed after being killed
docker run --rm --net redisnet --name redis -d redis
# Now you should see Redis container running
docker ps
# Launch redis-cli that is automatically removed after exit
docker run --rm --net redisnet --name redis-cli -it goodsmileduck/redis-cli redis-cli -h redis.redisnet
# After you are done with experimenting, kill Redis container
docker kill redis
NOTE: You can add
-p 127.0.0.1:6379:6379
to your redis container to access port locally and not only through redis-cli in the docker container.
docker-compose up
docker exec -it redis-1 redis-cli -p 7000 --cluster create \
192.168.0.2:7000 \
192.168.0.3:7001 \
192.168.0.4:7002 \
192.168.0.5:7003 \
192.168.0.6:7004 \
192.168.0.7:7005 \
--cluster-replicas 1
Then type yes
and you are ready to go.
NOTE: use
-c
to enable cluster mode
docker exec -it redis-1 redis-cli -c -p 7000
docker-compose down
David Procházka | Josef Podaný | Matěj Tužil |
---|---|---|
github.com/ProchazkaDavid |
github.com/josefpodany |
github.com/xtuzil |