본문 바로가기
강의 실습/비전공자도 이해할 수 있는 Docker 입문 실전

[실습] Docker로 Redis 실행시켜보기

by jint 2026. 5. 5.

1. Docker로 Redis 실행
1) Redis 이미지를 바탕으로 컨테이너 실행
Docker Hub - redis : https://hub.docker.com/_/redis

 

redis - Official Image | Docker Hub

⁠Quick reference ⁠Supported tags and respective Dockerfile links 8.8-m03, 8.8-m03-trixie⁠ 8.8-m03-alpine, 8.8-m03-alpine3.23⁠ 8.6.2, 8.6, 8, 8.6.2-trixie, 8.6-trixie, 8-trixie, latest, trixie⁠ 8.6.2-alpine, 8.6-alpine, 8-alpine, 8.6.2-alpine3.23,

hub.docker.com


- Windows PowerShell

PS C:\Users\admin> docker run -d -p 6379:6379 redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
2b8951cd65b5: Pull complete
14d3b17b0010: Pull complete
9e0f42ff49e1: Pull complete
97afe6025aa9: Pull complete
3531af2bc2a9: Pull complete
4f4fb700ef54: Pull complete
d55df8e0f53d: Pull complete
f426aaaf8949: Download complete
ff0fc1b2ba98: Download complete
Digest: sha256:832d7785830f3f4b559300e6191fc914b15642c1935252338825cf4332200148
Status: Downloaded newer image for redis:latest
e37cd163171c7c1f3decb2d067b3b5636cf557355bd93f0e46ca47a38cc82091

What's next:
    Debug this container error with Gordon → docker ai "help me fix this container error"
docker: Error response from daemon: ports are not available: exposing port TCP 0.0.0.0:6379 -> 127.0.0.1:0: listen tcp 0.0.0.0:6379: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

Run 'docker run --help' for more information


호스트의 6379 포트가 이미 사용중이라서 해당 포트를 죽이고 다시 컨테이너 실행
[PowerShell] 특정 포트 확인 및 죽이기 : https://log-laboratory.tistory.com/8

 

[PowerShell] 특정 포트 확인 및 죽이기

특정 포트 확인 및 죽이기 (PowerShell, Cmd 창 모두 적용 가능) 1. 특정 포트의 PID 확인 netstat -nao | findstr "port번호" 2. 해당 PID 죽이기 taskkill /f /pid "PID 번호" 예시 ( port : 7000)

log-laboratory.tistory.com


* 열린 포트 목록 보기: netstat -an | findstr LISTENING

- Windows PowerShell

PS C:\Users\admin> netstat -an | findstr "6379"
  UDP    0.0.0.0:63795          *:*
  UDP    0.0.0.0:63796          *:*
  UDP    [::]:63797             *:*
PS C:\Users\admin> taskkill /f /pid "4180"
성공: 프로세스(PID 4180)가 종료되었습니다.
PS C:\Users\admin> docker run -d -p 6379:6379 redis
8af8ab623f180a67e1543123bd58901911126944f81533be3a54150b7dd99113


로컬 환경에 redis 이미지가 없으면 Docker Hub 으로부터 자동으로 다운로드
redis 기본 실행 포트가 6379 이다.

2) 다운로드 된 이미지 확인
- Windows PowerShell

PS C:\Users\admin> docker image ls
                                                                                                                                                                                             i Info →   U  In Use
IMAGE          ID             DISK USAGE   CONTENT SIZE   EXTRA
redis:latest   832d7785830f        204MB         55.3MB    U


3) 컨테이너가 잘 실행되고 있는 지 확인
- Windows PowerShell

PS C:\Users\admin> docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                         NAMES
8af8ab623f18   redis     "docker-entrypoint.s…"   26 seconds ago   Up 25 seconds   0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp   charming_austin


4) 컨테이너 실행시킬 때 에러 없이 잘 실행됐는 지 로그 체크
- Windows PowerShell

PS C:\Users\admin> docker logs 8af8
Starting Redis Server
1:C 05 May 2026 08:38:52.103 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 05 May 2026 08:38:52.104 * Redis version=8.6.2, bits=64, commit=00000000, modified=1, pid=1, just started
1:C 05 May 2026 08:38:52.104 * Configuration loaded
1:M 05 May 2026 08:38:52.104 * monotonic clock: POSIX clock_gettime
1:M 05 May 2026 08:38:52.106 * Running mode=standalone, port=6379.
1:M 05 May 2026 08:38:52.107 * <bf> RedisBloom version 8.6.0 (Git=unknown)
1:M 05 May 2026 08:38:52.107 * <bf> Registering configuration options: [
1:M 05 May 2026 08:38:52.107 * <bf>     { bf-error-rate       :      0.01 }
1:M 05 May 2026 08:38:52.107 * <bf>     { bf-initial-size     :       100 }
1:M 05 May 2026 08:38:52.107 * <bf>     { bf-expansion-factor :         2 }
1:M 05 May 2026 08:38:52.107 * <bf>     { cf-bucket-size      :         2 }
1:M 05 May 2026 08:38:52.107 * <bf>     { cf-initial-size     :      1024 }
1:M 05 May 2026 08:38:52.107 * <bf>     { cf-max-iterations   :        20 }
1:M 05 May 2026 08:38:52.107 * <bf>     { cf-expansion-factor :         1 }
1:M 05 May 2026 08:38:52.107 * <bf>     { cf-max-expansions   :        32 }
1:M 05 May 2026 08:38:52.107 * <bf> ]
1:M 05 May 2026 08:38:52.107 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
1:M 05 May 2026 08:38:52.119 * <search> Redis version found by RedisSearch : 8.6.2 - oss
1:M 05 May 2026 08:38:52.119 * <search> RediSearch version 8.6.0 (Git=7782b97)
1:M 05 May 2026 08:38:52.119 * <search> Low level api version 1 initialized successfully
1:M 05 May 2026 08:38:52.119 * <search> gc: ON, prefix min length: 2, min word length to stem: 4, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, oom policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results:  1000000, default scorer: BM25STD,
1:M 05 May 2026 08:38:52.120 * <search> Initialized thread pools!
1:M 05 May 2026 08:38:52.120 * <search> Disabled workers threadpool of size 0
1:M 05 May 2026 08:38:52.120 * <search> Subscribe to config changes
1:M 05 May 2026 08:38:52.120 * <search> Subscribe to cluster slot migration events
1:M 05 May 2026 08:38:52.120 * <search> Enabled role change notification
1:M 05 May 2026 08:38:52.120 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
1:M 05 May 2026 08:38:52.121 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
1:M 05 May 2026 08:38:52.122 * <timeseries> RedisTimeSeries version 80600, git_sha=05fd355db748676861dc4c17d19c8c1ca74c0154
1:M 05 May 2026 08:38:52.122 * <timeseries> Redis version found by RedisTimeSeries : 8.6.2 - oss
1:M 05 May 2026 08:38:52.122 * <timeseries> Registering configuration options: [
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-compaction-policy   :              }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-num-threads         :            3 }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-retention-policy    :            0 }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-duplicate-policy    :        block }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-chunk-size-bytes    :         4096 }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-encoding            :   compressed }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-ignore-max-time-diff:            0 }
1:M 05 May 2026 08:38:52.122 * <timeseries>     { ts-ignore-max-val-diff :     0.000000 }
1:M 05 May 2026 08:38:52.122 * <timeseries> ]
1:M 05 May 2026 08:38:52.122 * <timeseries> Detected redis oss
1:M 05 May 2026 08:38:52.123 * <timeseries> Subscribe to ASM events
1:M 05 May 2026 08:38:52.123 * <timeseries> Enabled diskless replication
1:M 05 May 2026 08:38:52.123 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
1:M 05 May 2026 08:38:52.125 * <ReJSON> Created new data type 'ReJSON-RL'
1:M 05 May 2026 08:38:52.126 * <ReJSON> version: 80600 git sha: unknown branch: unknown
1:M 05 May 2026 08:38:52.126 * <ReJSON> Exported RedisJSON_V1 API
1:M 05 May 2026 08:38:52.126 * <ReJSON> Exported RedisJSON_V2 API
1:M 05 May 2026 08:38:52.126 * <ReJSON> Exported RedisJSON_V3 API
1:M 05 May 2026 08:38:52.126 * <ReJSON> Exported RedisJSON_V4 API
1:M 05 May 2026 08:38:52.126 * <ReJSON> Exported RedisJSON_V5 API
1:M 05 May 2026 08:38:52.126 * <ReJSON> Exported RedisJSON_V6 API
1:M 05 May 2026 08:38:52.126 * <ReJSON> Enabled diskless replication
1:M 05 May 2026 08:38:52.126 * <ReJSON> Initialized shared string cache, thread safe: true.
1:M 05 May 2026 08:38:52.126 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
1:M 05 May 2026 08:38:52.126 * <search> Acquired RedisJSON_V6 API
1:M 05 May 2026 08:38:52.127 * Server initialized
1:M 05 May 2026 08:38:52.127 * Ready to accept connections tcp
1:M 05 May 2026 08:38:52.127 # WARNING: Redis does not require authentication and is not protected by network restrictions. Redis will accept connections from any IP address on any network interface.


5) Redis 컨테이너에 접속
- Windows PowerShell

PS C:\Users\admin> docker exec -it 8af8 bash
root@8af8ab623f18:/data# ls
root@8af8ab623f18:/data# cd ..
root@8af8ab623f18:/# ls
bin  boot  data  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@8af8ab623f18:/# pwd
/


6) 컨테이너에서 redis 사용해보기
redis-cli 명령어 정리 : https://freeblogger.tistory.com/10

 

redis-cli 명령어 정리

redis-cli 명령어 정리 redis-cli 접속 호스트명과 포트번호를 생략하면 localhost의 6379로 접속됩니다. -n db번호 -a 비밀번호 -s 소켓 -u 서버 url 등 접속 시 다양한 옵션 설정이 사용 가능합니다. # localhost

freeblogger.tistory.com


- Windows PowerShell

root@8af8ab623f18:/# redis-cli
127.0.0.1:6379> set 1 jint
OK
127.0.0.1:6379> get 1
"jint"
127.0.0.1:6379> exit
root@8af8ab623f18:/# exit
exit

What's next:
    Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug 8af8
    Learn more at https://docs.docker.com/go/debug-cli/


7) 컨테이너 삭제 & 이미지 삭제
- Windows PowerShell

PS C:\Users\admin> docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                         NAMES
8af8ab623f18   redis     "docker-entrypoint.s…"   7 minutes ago   Up 7 minutes   0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp   charming_austin
PS C:\Users\admin> docker rm -f 8af8
8af8
PS C:\Users\admin> docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
PS C:\Users\admin> docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS    PORTS     NAMES
e37cd163171c   redis     "docker-entrypoint.s…"   15 minutes ago   Created             vigilant_shockley
PS C:\Users\admin> docker image ls
                                                                                                                                                                                             i Info →   U  In Use
IMAGE          ID             DISK USAGE   CONTENT SIZE   EXTRA
redis:latest   832d7785830f        204MB         55.3MB    U
PS C:\Users\admin> docker image rm redis
Error response from daemon: conflict: unable to delete redis:latest (must be forced) - container e37cd163171c is using its referenced image 832d7785830f
PS C:\Users\admin> docker rm e37c
e37c
PS C:\Users\admin> docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
PS C:\Users\admin> docker image rm redis
Untagged: redis:latest
Deleted: sha256:832d7785830f3f4b559300e6191fc914b15642c1935252338825cf4332200148
PS C:\Users\admin> docker image ls
                                                                                                                                                                                             i Info →   U  In Use
IMAGE   ID             DISK USAGE   CONTENT SIZE   EXTRA

 

그림으로 이해하기



참고링크 : https://www.inflearn.com/course/%EB%B9%84%EC%A0%84%EA%B3%B5%EC%9E%90-docker-%EC%9E%85%EB%AC%B8-%EC%8B%A4%EC%A0%84?cid=334085

 

비전공자도 이해할 수 있는 Docker 입문/실전| JSCODE 박재성 - 인프런 강의

현재 평점 4.9점 수강생 14,444명인 강의를 만나보세요. 비전공자 입장에서도 쉽게 이해할 수 있고, 실전에서 바로 적용 가능한 Docker 입문/실전 강의를 만들어봤습니다! Docker 기본 개념, Spring Boot를

www.inflearn.com

댓글