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

[실습] Docker Compose로 Redis 실행시키기

by jint 2026. 5. 26.

현업에서도 컨테이너가 여러 개가 아닌 1개일 때도 Docker Compose 를 사용할 수 있다. 긴 명령어를 간소화할 수 있기 때문이다.


1. Docker CLI 로 컨테이너 실행

$ docker run -d -p 6379:6379 redis



2. Docker Compose 로 컨테이너 실행
1) compose.yml 파일 작성
- compose-practice/compose.yml

services:
    my-cache-server:
        image: redis
        ports:
            - 6379:6379


2) compose 파일 실행
- Windows PowerShell

PS C:\Users\admin> cd .\compose-practice\
PS C:\Users\admin\compose-practice> docker compose up -d
[+] up 11/11
 ✔ Image redis                                  Pulled                                                                                                                                                       5.3s
 ✔ Network compose-practice_default             Created                                                                                                                                                      0.0s
 ✔ Container compose-practice-my-cache-server-1 Started                                                                                                                                                      0.7s

What's next:
    Filter, search, and stream logs from all your Compose services
    in one place with Docker Desktop's Logs view. docker-desktop://dashboard/logs?appId=compose-practice


3) compose 실행 현황 확인
- Windows PowerShell

PS C:\Users\admin\compose-practice> docker compose ps
NAME                                 IMAGE     COMMAND                   SERVICE           CREATED          STATUS          PORTS
compose-practice-my-cache-server-1   redis     "docker-entrypoint.s…"   my-cache-server   29 seconds ago   Up 29 seconds   0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp
PS C:\Users\admin\compose-practice> docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                         NAMES
6cd9b047738a   redis     "docker-entrypoint.s…"   34 seconds ago   Up 34 seconds   0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp   compose-practice-my-cache-server-1


4) 컨테이너 로그 확인
- Windows PowerShell

PS C:\Users\admin\compose-practice> docker compose logs
my-cache-server-1  | Starting Redis Server
my-cache-server-1  | 1:C 26 May 2026 13:38:11.751 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
my-cache-server-1  | 1:C 26 May 2026 13:38:11.751 * Redis version=8.6.3, bits=64, commit=00000000, modified=1, pid=1, just started
my-cache-server-1  | 1:C 26 May 2026 13:38:11.751 * Configuration loaded
my-cache-server-1  | 1:M 26 May 2026 13:38:11.752 * monotonic clock: POSIX clock_gettime
my-cache-server-1  | 1:M 26 May 2026 13:38:11.752 * Running mode=standalone, port=6379.
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf> RedisBloom version 8.6.2 (Git=unknown)
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf> Registering configuration options: [
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { bf-error-rate       :      0.01 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { bf-initial-size     :       100 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { bf-expansion-factor :         2 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { cf-bucket-size      :         2 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { cf-initial-size     :      1024 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { cf-max-iterations   :        20 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { cf-expansion-factor :         1 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf>        { cf-max-expansions   :        32 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * <bf> ]
my-cache-server-1  | 1:M 26 May 2026 13:38:11.753 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Redis version found by RedisSearch : 8.6.3 - oss
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> RediSearch version 8.6.7 (Git=3020486)
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Low level api version 1 initialized successfully
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <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,
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Initialized thread pools!
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Disabled workers threadpool of size 0
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Subscribe to config changes
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Subscribe to cluster slot migration events
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Enabled role change notification
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
my-cache-server-1  | 1:M 26 May 2026 13:38:11.755 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> RedisTimeSeries version 80602, git_sha=5d7c61c9f861b5cb83989463595c2c9f6b2bfe63
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> Redis version found by RedisTimeSeries : 8.6.3 - oss
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> Registering configuration options: [
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-compaction-policy   :              }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-num-threads         :            3 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-retention-policy    :            0 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-duplicate-policy    :        block }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-chunk-size-bytes    :         4096 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-encoding            :   compressed }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-ignore-max-time-diff:            0 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries>        { ts-ignore-max-val-diff :     0.000000 }
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> ]
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> Detected redis oss
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> Subscribe to ASM events
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <timeseries> Enabled diskless replication
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Created new data type 'ReJSON-RL'
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> version: 80600 git sha: unknown branch: unknown
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V1 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V2 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V3 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V4 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V5 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V6 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Enabled diskless replication
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <ReJSON> Initialized shared string cache, thread safe: true.
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
my-cache-server-1  | 1:M 26 May 2026 13:38:11.756 * <search> Acquired RedisJSON_V6 API
my-cache-server-1  | 1:M 26 May 2026 13:38:11.757 * Server initialized
my-cache-server-1  | 1:M 26 May 2026 13:38:11.757 * Ready to accept connections tcp
my-cache-server-1  | 1:M 26 May 2026 13:38:11.757 # 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.

What's next:
    Filter, search, and stream logs from all your Compose services
    in one place with Docker Desktop's Logs view. docker-desktop://dashboard/logs?appId=compose-practice
PS C:\Users\admin\compose-practice> docker logs 6cd9
Starting Redis Server
1:C 26 May 2026 13:38:11.751 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 26 May 2026 13:38:11.751 * Redis version=8.6.3, bits=64, commit=00000000, modified=1, pid=1, just started
1:C 26 May 2026 13:38:11.751 * Configuration loaded
1:M 26 May 2026 13:38:11.752 * monotonic clock: POSIX clock_gettime
1:M 26 May 2026 13:38:11.752 * Running mode=standalone, port=6379.
1:M 26 May 2026 13:38:11.753 * <bf> RedisBloom version 8.6.2 (Git=unknown)
1:M 26 May 2026 13:38:11.753 * <bf> Registering configuration options: [
1:M 26 May 2026 13:38:11.753 * <bf>     { bf-error-rate       :      0.01 }
1:M 26 May 2026 13:38:11.753 * <bf>     { bf-initial-size     :       100 }
1:M 26 May 2026 13:38:11.753 * <bf>     { bf-expansion-factor :         2 }
1:M 26 May 2026 13:38:11.753 * <bf>     { cf-bucket-size      :         2 }
1:M 26 May 2026 13:38:11.753 * <bf>     { cf-initial-size     :      1024 }
1:M 26 May 2026 13:38:11.753 * <bf>     { cf-max-iterations   :        20 }
1:M 26 May 2026 13:38:11.753 * <bf>     { cf-expansion-factor :         1 }
1:M 26 May 2026 13:38:11.753 * <bf>     { cf-max-expansions   :        32 }
1:M 26 May 2026 13:38:11.753 * <bf> ]
1:M 26 May 2026 13:38:11.753 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
1:M 26 May 2026 13:38:11.755 * <search> Redis version found by RedisSearch : 8.6.3 - oss
1:M 26 May 2026 13:38:11.755 * <search> RediSearch version 8.6.7 (Git=3020486)
1:M 26 May 2026 13:38:11.755 * <search> Low level api version 1 initialized successfully
1:M 26 May 2026 13:38:11.755 * <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 26 May 2026 13:38:11.755 * <search> Initialized thread pools!
1:M 26 May 2026 13:38:11.755 * <search> Disabled workers threadpool of size 0
1:M 26 May 2026 13:38:11.755 * <search> Subscribe to config changes
1:M 26 May 2026 13:38:11.755 * <search> Subscribe to cluster slot migration events
1:M 26 May 2026 13:38:11.755 * <search> Enabled role change notification
1:M 26 May 2026 13:38:11.755 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
1:M 26 May 2026 13:38:11.755 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
1:M 26 May 2026 13:38:11.756 * <timeseries> RedisTimeSeries version 80602, git_sha=5d7c61c9f861b5cb83989463595c2c9f6b2bfe63
1:M 26 May 2026 13:38:11.756 * <timeseries> Redis version found by RedisTimeSeries : 8.6.3 - oss
1:M 26 May 2026 13:38:11.756 * <timeseries> Registering configuration options: [
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-compaction-policy   :              }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-num-threads         :            3 }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-retention-policy    :            0 }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-duplicate-policy    :        block }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-chunk-size-bytes    :         4096 }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-encoding            :   compressed }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-ignore-max-time-diff:            0 }
1:M 26 May 2026 13:38:11.756 * <timeseries>     { ts-ignore-max-val-diff :     0.000000 }
1:M 26 May 2026 13:38:11.756 * <timeseries> ]
1:M 26 May 2026 13:38:11.756 * <timeseries> Detected redis oss
1:M 26 May 2026 13:38:11.756 * <timeseries> Subscribe to ASM events
1:M 26 May 2026 13:38:11.756 * <timeseries> Enabled diskless replication
1:M 26 May 2026 13:38:11.756 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
1:M 26 May 2026 13:38:11.756 * <ReJSON> Created new data type 'ReJSON-RL'
1:M 26 May 2026 13:38:11.756 * <ReJSON> version: 80600 git sha: unknown branch: unknown
1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V1 API
1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V2 API
1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V3 API
1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V4 API
1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V5 API
1:M 26 May 2026 13:38:11.756 * <ReJSON> Exported RedisJSON_V6 API
1:M 26 May 2026 13:38:11.756 * <ReJSON> Enabled diskless replication
1:M 26 May 2026 13:38:11.756 * <ReJSON> Initialized shared string cache, thread safe: true.
1:M 26 May 2026 13:38:11.756 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
1:M 26 May 2026 13:38:11.756 * <search> Acquired RedisJSON_V6 API
1:M 26 May 2026 13:38:11.757 * Server initialized
1:M 26 May 2026 13:38:11.757 * Ready to accept connections tcp
1:M 26 May 2026 13:38:11.757 # 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.

What's next:
    View and search logs for all containers in one place
    with Docker Desktop's Logs view. docker-desktop://dashboard/logs


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

PS C:\Users\admin\compose-practice> docker exec -it 6cd9 bash


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@6cd9b047738a:/data# 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@6cd9b047738a:/data# exit
exit

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


7) compose 로 실행된 컨테이너 중지 후 삭제
- Windows PowerShell

PS C:\Users\admin\compose-practice> docker compose down
[+] down 2/2
 ✔ Container compose-practice-my-cache-server-1 Removed                                                                                                                                                      0.4s
 ✔ Network compose-practice_default             Removed                                                                                                                                                      0.3s
PS C:\Users\admin\compose-practice> docker compose ps
NAME      IMAGE     COMMAND   SERVICE   CREATED   STATUS    PORTS
PS C:\Users\admin\compose-practice> docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES



참고링크 : 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,483명인 강의를 만나보세요. 비전공자 입장에서도 쉽게 이해할 수 있고, 실전에서 바로 적용 가능한 Docker 입문/실전 강의를 만들어봤습니다! Docker 기본 개념, Spring Boot를

www.inflearn.com

댓글