ふたりで

docker-desktop + mongodb compose 본문

docker

docker-desktop + mongodb compose

graykang 2025. 1. 6. 14:36
728x90
반응형
SMALL

docker에 mongodb만 컨테이너로 실행시 참고.

# C:\docker-test\docker-workJob\mongodb-container> docker-compose.yml

version: '3.8'

services:
  db_mongodb:
    image: "mongo:latest"
    container_name: db_mongodb_receipt
    ports:
      - "27017:27017"  # 필요에 따라 주석 처리
    environment:
      MONGO_INITDB_ROOT_USERNAME: "root"
      MONGO_INITDB_ROOT_PASSWORD: "12345"  # 추후.env 파일에서 불러오기
    volumes:
      - mongodb_data_receipt:/data/db
    healthcheck:
      test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  mongodb_data_receipt:
반응형
728x90
SMALL

 

# yml 파일 실행 및 docker 명령어.

PS C:\docker-test\docker-workJob\mongodb-container> docker-compose up -d
time="2025-01-06T13:58:46+09:00" level=warning msg="C:\\docker-test\\docker-workJob\\mongodb-container\\docker-compose.yml: `version` is obsolete"
[+] Running 9/9
 ✔ db_mongodb Pulled                                                                                                                                                                                 35.7s 
   ✔ de44b265507a Pull complete                                                                                                                                                                       6.5s 
   ✔ add2cfa32b4d Pull complete                                                                                                                                                                       6.6s 
   ✔ 0d3422d31c84 Pull complete                                                                                                                                                                       7.0s 
   ✔ e9869afb5187 Pull complete                                                                                                                                                                       7.1s 
   ✔ 9284108c06f8 Pull complete                                                                                                                                                                       7.2s 
   ✔ 17351a831ef1 Pull complete                                                                                                                                                                       7.3s 
   ✔ 2613644e011d Pull complete                                                                                                                                                                      31.8s 
   ✔ 05cc0f1cded4 Pull complete                                                                                                                                                                      31.8s 
[+] Running 3/3
 ✔ Network mongodb-container_default                Created                                                                                                                                           0.1s 
 ✔ Volume "mongodb-container_mongodb_data_receipt"  Created                                                                                                                                           0.0s 
 ✔ Container db_mongodb_receipt                     Started                                                                                                                                          10.0s 
PS C:\docker-test\docker-workJob\mongodb-container>

 

 

728x90
반응형
LIST
Comments