Docker Compose란?

Docker Compose 파일 작성

version: '3.7'
services:
  node:
    build: "./typescript_server"
    container_name: typescript_server
    restart: always
    environment:
      HOST_IP: ${HOST_IP}
    volumes:
      - ./typescript_server:/app
      - /app/node_modules
    ports:
      - 3000:3000
    depends_on:
      - db
    links:
      - db
    networks:
      - default

  db:
    image: mysql:5.7
    container_name: typescript_server-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 1q2w3e4r1!
      MYSQL_USER: typescript_server_db
      MYSQL_PASSWORD: 1q2w3e4r1!
      MYSQL_DATABASE: typescript_api_study
    ports:
      - "3306:3306"
    networks:
      - default
    volumes:
      - ./db_data:/var/lib/mysql

networks:
  default:
    driver: bridge
    ipam:
      config:
        - subnet: 172.32.0.0/24

version

services

image

ports

docker compose 실헹

# docker-compose.yaml file path
$ docker-compose up

참고자료

2. Docker Compose로 Nodejs 개발/배포환경 구성하기 - Docker Compose로 개선하기