Skip to content

micro-service-architecture/docker-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-files

목차

애플리케이션 배포 Docker Container

Mysql 배포

도커 파일 생성

FROM mariadb:10.5.17
ENV MYSQL_ROOT_PASSWORD test1357
ENV MYSQL_DATABASE mydb
COPY ./data /var/lib/mysql
EXPOSE 3306
ENTRYPOINT [ "mysqld", "--user=root" ]
  • COPY : ./data
    Host PC에 있는 데이터 경로를 복사하여 Dockerfile 과 같은 경로로 옮긴다.
    • MacOS
      image
    • Window image

도커 파일 빌드

docker build -t yong7317/my-mariadb:1.0 .

도커 파일 실행

docker run -d -p 3306:3306  --network ecommerce-network --name mariadb yong7317/my-mariadb:1.0

mariaDB 컨테이너 실행

docker exec -it mariadb /bin/bash

image image

외부 접속 권한 설정

grant all privileges on *.* to 'root'@'%' identified by 'test1357';
flush privileges

image

Kafka 배포

docker-compose-single-broker.yml 파일 수정

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
    networks: 
      my-network:
        ipv4_address: 172.18.0.100
  kafka:
    # build: .
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 172.18.0.101
      KAFKA_CREATE_TOPICS: "test:1:1"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on: 
      - zookeeper
    networks: 
      my-network:
        ipv4_address: 172.18.0.101
networks: 
  my-network:
    external: true
    name: ecommerce-network # 172.18.0.1~

docker-compose 실행

C:\docker-files\kafka-docker> docker-compose -f docker-compose-single-broker.yml up -d

Zipkin 배포

도커 파일 실행

docker run -d -p 9411:9411 --network ecommerce-network --name zipkin openzipkin/zipkin

Prometheus 배포

prometheus.yml 파일 수정

...
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["prometheus:9090"]
  - job_name: 'user-service'
    scrape_interval: 15s
    metrics_path: '/user-service/actuator/prometheus'
    static_configs:
    - targets: ['apigateway-service:8000']
  - job_name: 'order-service'
    scrape_interval: 15s
    metrics_path: '/order-service/actuator/prometheus'
    static_configs:
    - targets: ['apigateway-service:8000']
  - job_name: 'apigateway-service'
    scrape_interval: 15s
    metrics_path: '/actuator/prometheus'
    static_configs:
    - targets: ['apigateway-service:8000']
    ...

도커 파일 실행

docker run -d -p 9090:9090 --network ecommerce-network --name prometheus -v C:\prometheus-2.40.2.windows-amd64/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus 

-v : VOLUME 옵션 설정

Grafana 배포

도커 파일 실행

docker run -d -p 3000:3000 --network ecommerce-network --name grafana grafana/grafana 

참고

https://velog.io/@shinmj1207/Apache-Kafka-Kafka-Spring-Boot-연동-오류-모음
https://stackoverflow.com/questions/67763076/connection-to-node-1-127-0-0-19092-could-not-be-established-broker-may-not

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published