본문 바로가기

Tech/Docker

[Docker] Docker Compose

반응형

compose multi-container Docker applications 정의하고 실행하는 도구이다. docker compose에서는 YAML 파일을 통해 애플리케이션 서비스를 설정할  있다.

 

compose 사용법은 기본적으로 3가지 단계를 거친다.

 

  1. app 환경을 Dockerfile 정의하여 어느 곳에서는 재사용할  있도록 한다.
  2. app 서비스들을 docker-compose.yml 파일에 정의하여 독립된 환경에서 함께 동작할  있도록 한다.
  3. 'docker compose up' 명령어를 통해 전체 app 실행시킨다. docker-compose binary 사용하여 'docker-compose up' 명령어를 사용해도 된다.

- docker-compose.yml

version: "3.9"
services:
  # web과 redis 두가지 service 정의
  # service - web
  web:
    # build from the Dockerfile in current directory
    build: .
    # binds the containser and the host machine to the exposed port, 5000
    ports:
      - "5000:5000"
    # mount the project directory (./) on the host to /code inside the container
    volumes:
      - .:/code
    # set the FLASK_ENV environment variable to development
    environment:
      FLASK_ENV: development
  # service - redis 
  redis:
    # use a public Redis image pulled from the Docker Hub registry
    image: "redis:alpine"

 

 

[reference]

- https://docs.docker.com/compose/gettingstarted/

 

Get started with Docker Compose

 

docs.docker.com

- https://github.com/rmk1075/Docker_Env

 

GitHub - rmk1075/Docker_Env: study about docker for setting up dev environment

study about docker for setting up dev environment. Contribute to rmk1075/Docker_Env development by creating an account on GitHub.

github.com

 

반응형

'Tech > Docker' 카테고리의 다른 글

[Docker] Docker Root Directory (도커 스토리지) 변경  (0) 2023.12.14
[Docker] Docker vs VM  (0) 2022.07.28
[Docker] Dockerfile 개념 정리  (0) 2021.09.04
[Docker] 도커 개념 정리  (0) 2021.04.13