공부/Docker

Docker 로 nextcloud, mysql, elasticsearch 연동 - 넥스트클라우드 실행

딸기버블티 2023. 2. 15. 11:21

1. docker-compose 파일 작성

docker-compose.yml

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data02:/usr/share/elasticsearch/data
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data03:/usr/share/elasticsearch/data
    networks:
      - elastic
  kib01:
    image: docker.elastic.co/kibana/kibana:7.7.1
    container_name: kib01
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_URL: http://es01:9200
      ELASTICSEARCH_HOSTS: http://es01:9200
    networks:
      - elastic
  app:
    image: nextcloud
    container_name: nextcloud
    ports:
      - 8087:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    restart: always
  db:
    image: mysql
    ports:
      - 3307:3306
    container_name: mysql
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_PASSWORD=jylee
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=jylee
volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local
  nextcloud:
  db:
networks:
  elastic:
    driver: bridge
 
cs

yaml 문법에 맞춰 잘 작성

 

es01, es02, es03 > 엘라스틱서치

kib01 > 키바나 (엘라스틱서치 인덱스 볼수있는곳)

app > 넥스트클라우드

db > 넥스트클라우드에 연결될 db 정보

 

 

 

2. docker-compose 파일 실행

cmd 창에서

docker-compose.yml 이 있는 디렉토리로 이동 후

docker-compose up -d 명령어 실행

 

디렉토리 이동은 cd "경로" 해주면 됨

ex) cd "C:\Users\LEE\getting-started"

 

 

3. 넥스트클라우드 실행

인터넷창에 localhost:8087 입력 후 실행

(8087 포트는 위에서 작성하는 docker-compose.yml 파일의 app > ports 부분에서 수정하면 된다)