[Docker] 도커로 Redis 시작하고 RDB 파일 불러오기

  1. 레디스 설정파일 redis.conf 작성 아래는 파일의 일부 (RDB 파일명과, RDB 위치를 지정해주어야 한다.)
# The filename where to dump the DB
dbfilename <RDB파일명>.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /bitnami/redis/data(RDB 위치시킬 디렉토리주소) 

2. RDB파일과 Redis.conf 파일을 적당한 위치(예제에서는 c:\data)에 위치시킨다.

3. 도커 Redis를 실행시킨다. -v 옵션을 이용해서 RDB파일이 있는 로컬 PC와 컨테이너의 볼륨을 연결하고, 여기서 Redis가 설정파일과, RDB파일을 찾도록하는 것이다.

docker run -d -p 6379:6379 --memory="4g" --name redis -e ALLOW_EMPTY_PASSWORD=yes -v c:\data:/bitnami/redis/data -v c:\data\redis.conf:/opt/bitnami/redis/mounted-etc/redis.conf bitnami/redis:latest 

5. 도커 컨테이너 접속

 docker exec -it redis /bin/bash

6. Redis-CLI 이용하여 키 조회 테스트

redis-cli >

keys *

Info

TTL <Key>

get <Key>