Skip to content

Commit d3bc53e

Browse files
authored
container-deployment: update docker-compose.md (#564)
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent f0aba67 commit d3bc53e

File tree

4 files changed

+36
-38
lines changed

4 files changed

+36
-38
lines changed
Loading
Loading
229 KB
Loading

container-deployment/docker-compose.md

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ Create `docker-compose.yml` for [Docker Compose](https://docs.docker.com/compose
3131
With the YAML file below, you can create and start all the services \(in this case, Apache, Fluentd, Elasticsearch, Kibana\) by one command:
3232

3333
```text
34-
version: "3"
3534
services:
3635
web:
3736
image: httpd
3837
ports:
39-
- "80:80"
40-
links:
38+
- "8080:80"
39+
depends_on:
4140
- fluentd
4241
logging:
4342
driver: "fluentd"
@@ -49,26 +48,36 @@ services:
4948
build: ./fluentd
5049
volumes:
5150
- ./fluentd/conf:/fluentd/etc
52-
links:
53-
- "elasticsearch"
51+
depends_on:
52+
# Launch fluentd after that elasticsearch is ready to connect
53+
elasticsearch:
54+
condition: service_healthy
5455
ports:
5556
- "24224:24224"
5657
- "24224:24224/udp"
5758
5859
elasticsearch:
59-
image: docker.elastic.co/elasticsearch/elasticsearch:7.13.1
60+
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.1
6061
container_name: elasticsearch
62+
hostname: elasticsearch
6163
environment:
62-
- "discovery.type=single-node"
63-
expose:
64-
- "9200"
64+
- discovery.type=single-node
65+
- xpack.security.enabled=false # Disable security for testing
66+
healthcheck:
67+
# Check whether service is ready
68+
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health"]
69+
interval: 10s
70+
retries: 5
71+
timeout: 5s
6572
ports:
66-
- "9200:9200"
73+
- 9200:9200
6774
6875
kibana:
69-
image: docker.elastic.co/kibana/kibana:7.13.1
70-
links:
71-
- "elasticsearch"
76+
image: docker.elastic.co/kibana/kibana:8.17.1
77+
depends_on:
78+
# Launch fluentd after that elasticsearch is ready to connect
79+
elasticsearch:
80+
condition: service_healthy
7281
ports:
7382
- "5601:5601"
7483
```
@@ -82,9 +91,9 @@ Create `fluentd/Dockerfile` with the following content using the Fluentd [offici
8291
```text
8392
# fluentd/Dockerfile
8493
85-
FROM fluent/fluentd:v1.12.0-debian-1.0
94+
FROM fluent/fluentd:edge-debian
8695
USER root
87-
RUN ["gem", "install", "fluent-plugin-elasticsearch", "--no-document", "--version", "5.0.3"]
96+
RUN ["gem", "install", "fluent-plugin-elasticsearch", "--no-document", "--version", "5.4.3"]
8897
USER fluent
8998
```
9099

@@ -128,51 +137,40 @@ NOTE: The detail of used parameters for `@type elasticsearch`, see [Elasticsearc
128137
Let's start the containers:
129138

130139
```text
131-
$ docker-compose up --detach
140+
$ docker compose up --detach
132141
```
133142

134143
Use `docker ps` command to verify that the four \(4\) containers are up and running:
135144

136145
```text
137146
$ docker ps
138-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
139-
60a8c3c8fcab httpd "httpd-foreground" 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp fluentd-elastic-kibana_web_1
140-
43df4d266636 fluentd-elastic-kibana_fluentd "tini -- /bin/entryp…" 6 minutes ago Up 6 minutes 5140/tcp, 0.0.0.0:24224->24224/tcp, 0.0.0.0:24224->24224/udp, :::24224->24224/tcp, :::24224->24224/udp fluentd-elastic-kibana_fluentd_1
141-
6a63ad1ddef1 docker.elastic.co/kibana/kibana:7.13.1 "/bin/tini -- /usr/l…" 6 minutes ago Up 6 minutes 0.0.0.0:5601->5601/tcp, :::5601->5601/tcp fluentd-elastic-kibana_kibana_1
142-
6168bd075497 docker.elastic.co/elasticsearch/elasticsearch:7.13.1 "/bin/tini -- /usr/l…" 6 minutes ago Up 6 minutes 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 9300/tcp elasticsearch
147+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
148+
7a489886d856 httpd "httpd-foreground" 36 seconds ago Up 14 seconds 0.0.0.0:8080->80/tcp, [::]:8080->80/tcp fluentd-elastic-kibana-web-1
149+
36ded62da733 fluentd-elastic-kibana-fluentd "tini -- /bin/entryp…" 36 seconds ago Up 15 seconds 5140/tcp, 0.0.0.0:24224->24224/tcp, 0.0.0.0:24224->24224/udp, :::24224->24224/tcp, :::24224->24224/udp fluentd-elastic-kibana-fluentd-1
150+
254b7692966f docker.elastic.co/kibana/kibana:8.17.1 "/bin/tini -- /usr/l…" 36 seconds ago Up 15 seconds 0.0.0.0:5601->5601/tcp, :::5601->5601/tcp fluentd-elastic-kibana-kibana-1
151+
187d3e5c2e08 docker.elastic.co/elasticsearch/elasticsearch:8.17.1 "/bin/tini -- /usr/l…" 37 seconds ago Up 35 seconds (healthy) 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 9300/tcp elasticsearch
143152
```
144153

145154
## Step 3: Generate `httpd` Access Logs
146155

147156
Use `curl` command to generate some access logs like this:
148157

149158
```text
150-
$ curl http://localhost:80/[1-10]
151-
<html><body><h1>It works!</h1></body></html>
152-
<html><body><h1>It works!</h1></body></html>
153-
<html><body><h1>It works!</h1></body></html>
154-
<html><body><h1>It works!</h1></body></html>
155-
<html><body><h1>It works!</h1></body></html>
156-
<html><body><h1>It works!</h1></body></html>
157-
<html><body><h1>It works!</h1></body></html>
158-
<html><body><h1>It works!</h1></body></html>
159-
<html><body><h1>It works!</h1></body></html>
159+
$ curl http://localhost:8080/
160160
<html><body><h1>It works!</h1></body></html>
161161
```
162162

163163
## Step 4: Confirm Logs from Kibana
164164

165-
Browse to `http://localhost:5601/app/management/kibana/indexPatterns` and set up the index name pattern for Kibana. Specify `fluentd-*` to `Index name or pattern` and click `Create`.
165+
Browse to [`http://localhost:5601/app/discover#/`](http://localhost:5601/app/discover#/) and create data view.
166+
![Kibana Discover](../.gitbook/assets/8.17_efk-kibana-discover-start-page.png)
166167

167-
![Kibana Index](../.gitbook/assets/7.10_efk-kibana-index.png) ![Kibana Timestamp](../.gitbook/assets/7.10_efk-kibana-timestamp.png)
168+
Specify `fluentd-*` to `Index pattern` and click `Save data view to Kibana`.
169+
![Kibana Discover](../.gitbook/assets/8.17_efk-kibana-create-data-view.png)
168170

169171
Then, go to `Discover` tab to check the logs. As you can see, logs are properly collected into the Elasticsearch + Kibana, via Fluentd.
170172

171-
![Kibana Discover](../.gitbook/assets/7.10_efk-kibana-discover.png)
172-
173-
## Code
174-
175-
The code is available at [https://github.com/digikin/fluentd-elastic-kibana](https://github.com/digikin/fluentd-elastic-kibana).
173+
![Kibana Discover](../.gitbook/assets/8.17_efk-kibana-discover.png)
176174

177175
## Learn More
178176

0 commit comments

Comments
 (0)