이유와 목적
- MSA 기반 서비스를 효율적으로 관리하고자 할 경우
- 회사의 리소스가 충분하지 않거나 많이 할당을 받지 못했을 경우
- 환경의 영향을 받지 않고 모든 환경에서 동일한 경험을 제공하고 싶을 경우
- 이미지 파일을 이용해서 운영상 버전 관리가 필요한 경우
- 기타 수많은 다른 이유...
어플리케이션 배포 환경 및 용어
설치 환경 및 설정
- Ubuntu 20.04
- Docker 24.0.5 (설치 과정 생략)
- Docker compose 2.20.3
## docker compose 설치 ##
# 필요한 디렉토리로 이동
mkdir -p ~/.docker/cli-plugins/
# 최신 버전 다운로드
curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
# 실행 권한 부여
chmod +x ~/.docker/cli-plugins/docker-compose
# 버전 확인
docker compose version
- docker-compose.yml 파일 생성 (docker-compose-postgresqldb.yml)
version: '3.8'
services:
db:
image: postgres:latest
container_name: postgresql_db
restart: always
environment:
POSTGRES_USER: your_username
POSTGRES_PASSWORD: your_password
POSTGRES_DB: your_database
ports:
- "15432:5432"
volumes:
- postgres_: /var/lib/postgresql/data # 이 볼륨을 컨테이너의 해당 경로에 마운트
volumes:
postgres_: {} # Docker가 관리하는 볼륨 정의 - 필요하면 자동 생성 옵션
컨테이너 서비스 실행 및 확인
$ docker compose -f docker-compose-postgresqldb.yml up -d
[+] Running 15/15
✔ db 14 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 15.6s
✔ c29f5b76f736 Pull complete 1.3s
✔ 3d0b32ee6c43 Pull complete 0.9s
✔ edea13d45b54 Pull complete 1.0s
✔ 91f23f0b9c1b Pull complete 1.8s
✔ 5ea2d101ccee Pull complete 2.1s
✔ 94f0cbfc26b6 Pull complete 2.2s
✔ 6565e7451acf Pull complete 2.6s
✔ 34047ddafe46 Pull complete 3.0s
✔ 3e0e9cc584ce Pull complete 5.1s
✔ 5d821824937c Pull complete 3.5s
✔ f69cbdd712da Pull complete 3.8s
✔ f62596e0b037 Pull complete 4.4s
✔ 63b9b48ec2a9 Pull complete 4.7s
✔ 1c47da8f7970 Pull complete 5.3s
[+] Running 3/3
✔ Network app_default Created 0.1s
✔ Volume "app_postgres_" Created 0.0s
✔ Container postgresql_db Started
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f23d031ca32c postgres:latest "docker-entrypoint.s…" 30 seconds ago Up 26 seconds 0.0.0.0:15432->5432/tcp, :::15432->5432/tcp postgresql_db
'Project' 카테고리의 다른 글
[Jenkins] 멀티모듈 파이프 라인 (feat. Jenkinsfile) (0) | 2025.02.26 |
---|---|
[QueryDSL] build.gradle 설정으로 cannot find symbol 오류 해결하기 (1) | 2025.02.20 |
[SpringBoot + Gradle] JAR, Bitbucket, Jenkins 원격 배포 환경 구축 (0) | 2021.11.11 |
스터디용 링크모음 (0) | 2021.05.17 |
관리자 풀스택 Migration 및 기능 개발일기 (0) | 2021.03.30 |