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

[실습] AWS EC2에 Spring Boot, MySQL, Redis 배포하기

by jint 2026. 6. 10.

1. AWS EC2 에서 Spring Boot, MySQL, Redis 배포
1) compose.yml 에 MySQL, Redis 관련 내용 추가
- Ubuntu

ubuntu@ip-172-31-41-193:~$ ls
aws  awscliv2.zip  docker-server
ubuntu@ip-172-31-41-193:~$ cd docker-server
ubuntu@ip-172-31-41-193:~/docker-server$ ls
compose.yml
ubuntu@ip-172-31-41-193:~/docker-server$ vi compose.yml


- Ubuntu Vim

services:
  docker-server:
    image: 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest
    ports:
      - 8080:8080
    depends_on: # my-db, my-cache-server의 컨테이너가 생성되고 healthy 하다고 판단 될 때, 해당 컨테이너를 생성한다.
      my-db:
        condition: service_healthy
      my-cache-server:
        condition: service_healthy

  my-db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: pwd123
      MYSQL_DATABASE: mydb # MySQL 최초 실행 시 mydb라는 데이터베이스를 생성해준다.
    volumes:
      - ./mysql_data:/var/lib/mysql
    ports:
      - 3306:3306
    healthcheck:
      test: ["CMD", "mysqladmin", "ping"] # MySQL이 healthy 한 지 판단할 수 있는 명령어
      interval: 5s # 5초 간격으로 체크
      retries: 10 # 10번까지 재시도

  my-cache-server:
    image: redis
    ports:
      - 6379:6379
    healthcheck:
      test: ["CMD", "redis-cli", "ping"] # redis가 healthy 한 지 판단할 수 있는 명령어
      interval: 5s
      retries: 10
~
~
~
~
...
:wq


- Ubuntu

ubuntu@ip-172-31-41-193:~/docker-server$ cat compose.yml
services:
  docker-server:
    image: 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest
    ports:
      - 8080:8080
    depends_on: # my-db, my-cache-server의 컨테이너가 생성되고 healthy 하다고 판단 될 때, 해당 컨테이너를 생성한다.
      my-db:
        condition: service_healthy
      my-cache-server:
        condition: service_healthy

  my-db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: pwd123
      MYSQL_DATABASE: mydb # MySQL 최초 실행 시 mydb라는 데이터베이스를 생성해준다.
    volumes:
      - ./mysql_data:/var/lib/mysql
    ports:
      - 3306:3306
    healthcheck:
      test: ["CMD", "mysqladmin", "ping"] # MySQL이 healthy 한 지 판단할 수 있는 명령어
      interval: 5s # 5초 간격으로 체크
      retries: 10 # 10번까지 재시도

  my-cache-server:
    image: redis
    ports:
      - 6379:6379
    healthcheck:
      test: ["CMD", "redis-cli", "ping"] # redis가 healthy 한 지 판단할 수 있는 명령어
      interval: 5s
      retries: 10


2) compose 파일 실행
- Ubuntu

ubuntu@ip-172-31-41-193:~/docker-server$ ls
compose.yml
ubuntu@ip-172-31-41-193:~/docker-server$ docker compose up --build -d
[+] up 3/3
 ! Image redis                                                                  Interrupted                                                                                                                    0.1s
 ✘ Image 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest Error unknown: failed to resolve reference "984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest": ...       0.1s
 ! Image mysql                                                                  Interrupted                                                                                                                    0.1s
Error response from daemon: unknown: failed to resolve reference "984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest": unexpected status from HEAD request to https://984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/v2/docker-server/manifests/latest: 403 Forbidden
ubuntu@ip-172-31-41-193:~/docker-server$ aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com

WARNING! Your credentials are stored unencrypted in '/home/ubuntu/.docker/config.json'.
Configure a credential helper to remove this warning. See
https://docs.docker.com/go/credential-store/

Login Succeeded


로컬에서 스프링 부트 프로젝트를 빌드 후 AWS ECR 에 업로드를 해야 한다.

- Windows PowerShell

PS C:\Users\admin\IdeaProjects\docker-ec2-spring-boot-server> ./gradlew clean build
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

BUILD SUCCESSFUL in 12s
8 actionable tasks: 8 executed
Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.5.1/userguide/configuration_cache_enabling.html
PS C:\Users\admin\IdeaProjects\docker-ec2-spring-boot-server> aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com
Login Succeeded
PS C:\Users\admin\IdeaProjects\docker-ec2-spring-boot-server> docker build -t docker-server .
[+] Building 4.5s (8/8) FINISHED                                                                                                                                                                               docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                           0.0s
 => => transferring dockerfile: 189B                                                                                                                                                                                           0.0s 
 => [internal] load metadata for docker.io/library/eclipse-temurin:17-jdk                                                                                                                                                      1.8s 
 => [auth] library/eclipse-temurin:pull token for registry-1.docker.io                                                                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                                                                0.0s 
 => [internal] load build context                                                                                                                                                                                              1.5s 
 => => transferring context: 19.81MB                                                                                                                                                                                           1.4s
 => CACHED [1/2] FROM docker.io/library/eclipse-temurin:17-jdk@sha256:859dc576f4af4fad89a179441e3f6dc9a549b86a2ffa5c740ed76b644810239b                                                                                         0.1s
 => => resolve docker.io/library/eclipse-temurin:17-jdk@sha256:859dc576f4af4fad89a179441e3f6dc9a549b86a2ffa5c740ed76b644810239b                                                                                                0.0s 
 => [2/2] COPY build/libs/*SNAPSHOT.jar /app.jar                                                                                                                                                                               0.1s 
 => exporting to image                                                                                                                                                                                                         0.9s 
 => => exporting layers                                                                                                                                                                                                        0.5s
 => => exporting manifest sha256:63c4115a56e4947312e3f638ff75263348b3f08f0515ec1c9290e2fe5a185223                                                                                                                              0.0s
 => => exporting config sha256:e066aa6dc5a900d9b4b3e7b96c929814bd0cf350553defb6e21624ae1ee0f776                                                                                                                                0.0s
 => => exporting attestation manifest sha256:68b8b159d02be5ad996ee8b8487333b0d71855f9df57d83733cfa52ecba24a95                                                                                                                  0.1s 
 => => exporting manifest list sha256:f741c5ca55aa9e3d3f70679b488880941c87c8f096a10f54023d0e0d1406ee2b                                                                                                                         0.0s 
 => => naming to docker.io/library/docker-server:latest                                                                                                                                                                        0.0s 
 => => unpacking to docker.io/library/docker-server:latest                                                                                                                                                                     0.1s 
                                                                                                                                                                                                                                    
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/qxm24sr3fo9aol5bdku61ahmc
PS C:\Users\admin\IdeaProjects\docker-ec2-spring-boot-server> docker tag docker-server:latest 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest
PS C:\Users\admin\IdeaProjects\docker-ec2-spring-boot-server> docker push 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest
The push refers to repository [984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server]
0179dfb07a7d: Layer already exists 
f2355d8d10e0: Layer already exists 
a32c42059121: Layer already exists 
4bced35ec338: Pushed 
223f9e56f573: Pushed 
6f5c5aa4e145: Layer already exists 
1074d15b60c9: Layer already exists 
1c24335ddd46: Layer already exists 
latest: digest: sha256:f741c5ca55aa9e3d3f70679b488880941c87c8f096a10f54023d0e0d1406ee2b size: 856


다시 compose 파일 실행

- Ubuntu

ubuntu@ip-172-31-41-193:~/docker-server$ docker compose up --build -d
[+] up 30/30
 ✔ Image redis                                                                  Pulled                                                                                                                        13.2s
 ✔ Image 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest Pulled                                                                                                                         1.0s
 ✔ Image mysql                                                                  Pulled                                                                                                                        24.7s
 ✔ Network docker-server_default                                                Created                                                                                                                        0.1s
 ✔ Container docker-server-my-db-1                                              Healthy                                                                                                                       17.0s
 ✔ Container docker-server-my-cache-server-1                                    Healthy                                                                                                                        6.5s
 ✔ Container docker-server-docker-server-1                                      Started                                                                                                                       17.5s
# 잘 실행되고 있는 지 확인
ubuntu@ip-172-31-41-193:~/docker-server$ docker compose ps
NAME                              IMAGE                                                                    COMMAND                  SERVICE           CREATED          STATUS                    PORTS
docker-server-docker-server-1     984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest   "java -jar /app.jar"     docker-server     46 seconds ago   Up 38 seconds             0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp
docker-server-my-cache-server-1   redis                                                                    "docker-entrypoint.s…"   my-cache-server   46 seconds ago   Up 45 seconds (healthy)   0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp
docker-server-my-db-1             mysql                                                                    "docker-entrypoint.s…"   my-db             46 seconds ago   Up 45 seconds (healthy)   0.0.0.0:3306->3306/tcp, [::]:3306->3306/tcp, 33060/tcp
ubuntu@ip-172-31-41-193:~/docker-server$ docker ps
CONTAINER ID   IMAGE                                                                    COMMAND                  CREATED              STATUS                        PORTS                                                    NAMES
42beb922b116   984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest   "java -jar /app.jar"     About a minute ago   Up 53 seconds                 0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp              docker-server-docker-server-1
e8117532ae88   redis                                                                    "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp              docker-server-my-cache-server-1
c66dcc4f5d53   mysql                                                                    "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:3306->3306/tcp, [::]:3306->3306/tcp, 33060/tcp   docker-server-my-db-1
ubuntu@ip-172-31-41-193:~/docker-server$ docker compose logs
my-cache-server-1  | Starting Redis Server
my-cache-server-1  | 1:C 10 Jun 2026 14:12:05.576 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
my-cache-server-1  | 1:C 10 Jun 2026 14:12:05.577 # WARNING Your system is configured to use the 'xen' clocksource which might lead to degraded performance. Check the result of the [slow-clocksource] system check: run 'redis-server --check-system' to check if the system's clocksource isn't degrading performance.
my-cache-server-1  | 1:C 10 Jun 2026 14:12:05.577 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
my-cache-server-1  | 1:C 10 Jun 2026 14:12:05.577 * Redis version=8.8.0, bits=64, commit=00000000, modified=1, pid=1, just started
my-cache-server-1  | 1:C 10 Jun 2026 14:12:05.577 * Configuration loaded
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.577 * Increased maximum number of open files to 10032 (it was originally set to 1024).
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.577 * monotonic clock: POSIX clock_gettime
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.582 * Running mode=standalone, port=6379.
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf> RedisBloom version 8.8.0 (Git=unknown)
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf> Registering configuration options: [
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { bf-error-rate       :      0.01 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { bf-initial-size     :       100 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { bf-expansion-factor :         2 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { cf-bucket-size      :         2 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { cf-initial-size     :      1024 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { cf-max-iterations   :        20 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { cf-expansion-factor :         1 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf>        { cf-max-expansions   :        32 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * <bf> ]
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.586 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.640 * <search> search-workers default: 1 (min of MAX_WORKER_THREADS=16 and CPU cores)
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.642 * <search> Redis version found by RedisSearch : 8.8.0 - oss
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.642 * <search> RediSearch version 8.8.0 (Git=d2ae026)
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.643 * <search> Low level api version 1 initialized successfully
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.643 * <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 10 Jun 2026 14:12:05.644 * <search> Initialized thread pools!
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.644 * <search> Enabled workers threadpool of size 1
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.650 * <search> Subscribe to config changes
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.650 * <search> Subscribe to cluster slot migration events
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.650 * <search> Enabled role change notification
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.650 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.650 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.654 * <timeseries> RedisTimeSeries version 80800, git_sha=42ca4f1078fca732b7f9256adbf25914d67e1cc9
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.654 * <timeseries> Redis version found by RedisTimeSeries : 8.8.0 - oss
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.654 * <timeseries> Registering configuration options: [
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-compaction-policy   :              }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-num-threads         :            3 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-libmr-protocol      :     INTERNAL }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-retention-policy    :            0 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-duplicate-policy    :        block }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-chunk-size-bytes    :         4096 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-encoding            :   compressed }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-ignore-max-time-diff:            0 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries>        { ts-ignore-max-val-diff :     0.000000 }
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries> ]
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.655 * <timeseries> Detected redis oss
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.659 * <timeseries> Subscribe to ASM events
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.659 * <timeseries> Enabled diskless replication
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.659 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.673 * <ReJSON> Created new data type 'ReJSON-RL'
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> version: 80800 git sha: unknown branch: unknown
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V1 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V2 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V3 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V4 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V5 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V6 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Exported RedisJSON_V7 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.676 * <ReJSON> Enabled diskless replication
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.677 * <ReJSON> Initialized shared string cache, thread safe: true.
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.677 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.677 * <search> Acquired RedisJSON_V7 API
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.678 * Server initialized
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.678 * Ready to accept connections tcp
my-cache-server-1  | 1:M 10 Jun 2026 14:12:05.678 # 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.
docker-server-1    | 
docker-server-1    |   .   ____          _            __ _ _
docker-server-1    |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
docker-server-1    | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
docker-server-1    |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
docker-server-1    |   '  |____| .__|_| |_|_| |_\__, | / / / /
docker-server-1    |  =========|_|==============|___/=/_/_/_/
docker-server-1    | 
docker-server-1    |  :: Spring Boot ::                (v4.0.6)
docker-server-1    | 
docker-server-1    | 2026-06-10T14:12:17.395Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] e.d.DockerEc2SpringBootServerApplication : Starting DockerEc2SpringBootServerApplication v0.0.1-SNAPSHOT using Java 17.0.19 with PID 1 (/app.jar started by root in /)
docker-server-1    | 2026-06-10T14:12:17.413Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] e.d.DockerEc2SpringBootServerApplication : No active profile set, falling back to 1 default profile: "default"
docker-server-1    | 2026-06-10T14:12:20.618Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] o.s.boot.tomcat.TomcatWebServer          : Tomcat initialized with port 8080 (http)
docker-server-1    | 2026-06-10T14:12:20.696Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
docker-server-1    | 2026-06-10T14:12:20.697Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/11.0.21]
docker-server-1    | 2026-06-10T14:12:21.412Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] b.w.c.s.WebApplicationContextInitializer : Root WebApplicationContext: initialization completed in 3843 ms
docker-server-1    | 2026-06-10T14:12:26.452Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] o.s.boot.tomcat.TomcatWebServer          : Tomcat started on port 8080 (http) with context path '/'
docker-server-1    | 2026-06-10T14:12:26.535Z  INFO 1 --- [docker-ec2-spring-boot-server] [           main] e.d.DockerEc2SpringBootServerApplication : Started DockerEc2SpringBootServerApplication in 11.437 seconds (process running for 13.662)
docker-server-1    | 2026-06-10T14:13:50.667Z  INFO 1 --- [docker-ec2-spring-boot-server] [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
docker-server-1    | 2026-06-10T14:13:50.669Z  INFO 1 --- [docker-ec2-spring-boot-server] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
docker-server-1    | 2026-06-10T14:13:50.671Z  INFO 1 --- [docker-ec2-spring-boot-server] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
my-db-1            | 2026-06-10 14:12:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.7.0-1.el9 started.
my-db-1            | 2026-06-10 14:12:06+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
my-db-1            | 2026-06-10 14:12:06+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.7.0-1.el9 started.
my-db-1            | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
my-db-1            | 2026-06-10T14:12:06.485244Z 0 [System] [MY-015015] [Server] MySQL Server - start.
my-db-1            | 2026-06-10T14:12:06.797264Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 9.7.0) starting as process 1
my-db-1            | 2026-06-10T14:12:06.797278Z 0 [System] [MY-015603] [Server] MySQL Server has access to 1 logical CPUs.
my-db-1            | 2026-06-10T14:12:06.797291Z 0 [System] [MY-015603] [Server] MySQL Server has access to 998215680 bytes of physical memory.
my-db-1            | 2026-06-10T14:12:06.821371Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
my-db-1            | 2026-06-10T14:12:08.272070Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
my-db-1            | 2026-06-10T14:12:08.662073Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
my-db-1            | 2026-06-10T14:12:08.689908Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
my-db-1            | 2026-06-10T14:12:08.849396Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
my-db-1            | 2026-06-10T14:12:08.849601Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
my-db-1            | 2026-06-10T14:12:08.858439Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
my-db-1            | 2026-06-10T14:12:08.933710Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
my-db-1            | 2026-06-10T14:12:08.934126Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '9.7.0'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

 

Docker Compose 로 배포


3) 컨테이너 종료 후 삭제, 이미지 삭제
- Ubuntu

ubuntu@ip-172-31-41-193:~/docker-server$ docker compose down
[+] down 4/4
 ✔ Container docker-server-docker-server-1   Removed                                                                                                                                                           6.9s
 ✔ Container docker-server-my-cache-server-1 Removed                                                                                                                                                           0.5s
 ✔ Container docker-server-my-db-1           Removed                                                                                                                                                           1.2s
 ✔ Network docker-server_default             Removed                                                                                                                                                           0.1s
ubuntu@ip-172-31-41-193:~/docker-server$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
ubuntu@ip-172-31-41-193:~/docker-server$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
ubuntu@ip-172-31-41-193:~/docker-server$ docker image ls
                                                                                                                                                                                               i Info →   U  In Use
IMAGE                                                                    ID             DISK USAGE   CONTENT SIZE   EXTRA
984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest   f741c5ca55aa        719MB          230MB        
mysql:latest                                                             c11782aa2a96        1.3GB          290MB        
redis:latest                                                             aa049e689e14        208MB         56.3MB        
ubuntu@ip-172-31-41-193:~/docker-server$ docker image rm f741 c117 aa04
Untagged: 984622551099.dkr.ecr.ap-northeast-2.amazonaws.com/docker-server:latest
Deleted: sha256:f741c5ca55aa9e3d3f70679b488880941c87c8f096a10f54023d0e0d1406ee2b
Untagged: mysql:latest
Deleted: sha256:c11782aa2a96624c1efc121768641d96954faa136d6aa82751b032d8c426ffbc
Untagged: redis:latest
Deleted: sha256:aa049e689e141a4358ad1d4562dc49c88a89fbab711fd8fcc33f684c80b26301



2. EC2 인스턴스 종료(삭제)
EC2 서비스의 인스턴스 메뉴에서 인스턴스 종료(삭제)

1) 보안 그룹 삭제
EC2 서비스의 네트워크 및 보안 > 보안 그룹 메뉴에서 보안 그룹 1개도 삭제 (test-server-security-group / nest-server-security-group)

2) 키 페어 삭제
EC2 서비스의 네트워크 및 보안 > 키 페어 메뉴에서 삭제할 키 페어 선택 후 작업 > 삭제


3. IAM 서비스 종료
1) 사용자 삭제
IAM 서비스의 액세스 관리 > IAM 사용자 메뉴에서 삭제할 사용자 선택 후 "삭제" 버튼 클릭
"액세스 키 비활성화" 버튼 클릭 후 삭제 진행


4. AWS ECR(Elastic Container Registry) 삭제
1) 이미지 삭제
Elastic Container Registry 서비스의 프라이빗 레지스트리 > 리포지토리 메뉴에서 해당 리포지토리 클릭하여 이미지 모두 선택 후 "삭제" 버튼 클릭

2) 리포지토리 삭제
Elastic Container Registry 서비스의 프라이빗 레지스트리 > 리포지토리 메뉴에서 해당 리포지토리 선택 후 "삭제" 버튼 클릭


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

www.inflearn.com

댓글