Skip to content

Commit f765aa3

Browse files
authored
Extract deprecated and customizing content (#390)
Split longer README.md into categorized markdown. Signed-off-by: Kentaro Hayashi <[email protected]>
1 parent d2550d2 commit f765aa3

File tree

3 files changed

+224
-212
lines changed

3 files changed

+224
-212
lines changed

DEPRECATED.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# About deprecated images
2+
3+
Put the historical deprecated contents here.
4+
5+
### Old v1.4 images
6+
7+
This is for backward compatibility. Use "Current images" instead.
8+
9+
- `v1.4.2-2.0`, `v1.4-2`
10+
[(v1.4/alpine/Dockerfile)][fluentd-1-4-alpine]
11+
- `v1.4.2-onbuild-2.0`, `v1.4-onbuild-2`
12+
[(v1.4/alpine-onbuild/Dockerfile)][fluentd-1-4-alpine-onbuild]
13+
- `v1.4.2-debian-2.0`, `v1.4-debian-2`
14+
[(v1.4/debian/Dockerfile)][fluentd-1-4-debian]
15+
- `v1.4.2-debian-onbuild-2.0`, `v1.4-debian-onbuild-2`, `edge-debian-onbuild`
16+
[(v1.4/debian-onbuild/Dockerfile)][fluentd-1-4-debian-onbuild]
17+
- `v1.4.2-windows-2.0`, `v1.4-windows-2`
18+
[(v1.4/windows/Dockerfile)][fluentd-1-4-windows]
19+
20+
### v0.12 images
21+
22+
Support of fluentd v0.12 has ended in 2019. We don't recommend v0.12 for new deployment.
23+
24+
- `v0.12.43-2.0`, `v0.12-2`
25+
[(v0.12/alpine/Dockerfile)][fluentd-0-12-alpine]
26+
- `v0.12.43-onbuild-2.0`, `v0.12-onbuild-2`
27+
[(v0.12/alpine-onbuild/Dockerfile)][fluentd-0-12-alpine-onbuild]
28+
- `v0.12.43-debian-2.0`, `v0.12-debian-2`
29+
[(v0.12/debian/Dockerfile)][fluentd-0-12-debian]
30+
- `v0.12.43-debian-onbuild-2.0`, `v0.12-debian-onbuild-2`
31+
[(v0.12/debian-onbuild/Dockerfile)][fluentd-0-12-debian-onbuild]
32+
33+
You can use older versions via tag. See [tag page on Docker Hub](https://hub.docker.com/r/fluent/fluentd/tags/).
34+
35+
We recommend to use debian version for production because it uses jemalloc to mitigate memory fragmentation issue.
36+
37+
### Tips for building your own older image
38+
39+
This section is for existing users. Don't recommend for new deployment.
40+
41+
#### Alpine version
42+
43+
```Dockerfile
44+
FROM fluent/fluentd:v1.3-onbuild-1
45+
46+
# below RUN includes plugin as examples elasticsearch is not required
47+
# you may customize including plugins as you wish
48+
49+
RUN apk add --no-cache --update --virtual .build-deps \
50+
sudo build-base ruby-dev \
51+
&& sudo gem install \
52+
fluent-plugin-elasticsearch \
53+
&& sudo gem sources --clear-all \
54+
&& apk del .build-deps \
55+
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
56+
```
57+
58+
#### Debian version
59+
60+
```Dockerfile
61+
FROM fluent/fluentd:v1.3-debian-onbuild-1
62+
63+
# below RUN includes plugin as examples elasticsearch is not required
64+
# you may customize including plugins as you wish
65+
66+
RUN buildDeps="sudo make gcc g++ libc-dev ruby-dev" \
67+
&& apt-get update \
68+
&& apt-get install -y --no-install-recommends $buildDeps \
69+
&& sudo gem install \
70+
fluent-plugin-elasticsearch \
71+
&& sudo gem sources --clear-all \
72+
&& SUDO_FORCE_REMOVE=yes \
73+
apt-get purge -y --auto-remove \
74+
-o APT::AutoRemove::RecommendsImportant=false \
75+
$buildDeps \
76+
&& rm -rf /var/lib/apt/lists/* \
77+
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
78+
```
79+
80+

HOWTOBUILD.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# How to build your own image
2+
3+
You can build a customized image based on Fluentd's image.
4+
Customized image can include plugins and `fluent.conf` file.
5+
6+
### 1. Create a working directory
7+
8+
We will use this directory to build a Docker image.
9+
Type following commands on a terminal to prepare a minimal project first:
10+
11+
```bash
12+
# Create project directory.
13+
mkdir custom-fluentd
14+
cd custom-fluentd
15+
16+
# Download default fluent.conf and entrypoint.sh. This file will be copied to the new image.
17+
# VERSION is v1.7 like fluentd version and OS is alpine or debian.
18+
# Full example is https://raw.githubusercontent.com/fluent/fluentd-docker-image/master/v1.10/debian/fluent.conf
19+
20+
curl https://raw.githubusercontent.com/fluent/fluentd-docker-image/master/VERSION/OS/fluent.conf > fluent.conf
21+
22+
curl https://raw.githubusercontent.com/fluent/fluentd-docker-image/master/VERSION/OS/entrypoint.sh > entrypoint.sh
23+
chmod +x entrypoint.sh
24+
25+
# Create plugins directory. plugins scripts put here will be copied to the new image.
26+
mkdir plugins
27+
28+
curl https://raw.githubusercontent.com/fluent/fluentd-docker-image/master/Dockerfile.sample > Dockerfile
29+
```
30+
31+
### 2. Customize `fluent.conf`
32+
33+
Documentation of `fluent.conf` is available at [docs.fluentd.org][3].
34+
35+
### 3. Customize Dockerfile to install plugins (optional)
36+
37+
You can install [Fluentd plugins][4] using Dockerfile.
38+
Sample Dockerfile installs `fluent-plugin-elasticsearch`.
39+
To add plugins, edit `Dockerfile` as following:
40+
41+
About deprecated old images, see [DEPRECATED](DEPRECATED.md).
42+
43+
#### Alpine version
44+
45+
```Dockerfile
46+
FROM fluent/fluentd:v1.17-1
47+
48+
# Use root account to use apk
49+
USER root
50+
51+
# below RUN includes plugin as examples elasticsearch is not required
52+
# you may customize including plugins as you wish
53+
RUN apk add --no-cache --update --virtual .build-deps \
54+
sudo build-base ruby-dev \
55+
&& sudo gem install fluent-plugin-elasticsearch \
56+
&& sudo gem sources --clear-all \
57+
&& apk del .build-deps \
58+
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
59+
60+
COPY fluent.conf /fluentd/etc/
61+
COPY entrypoint.sh /bin/
62+
63+
USER fluent
64+
```
65+
66+
#### Debian version
67+
68+
```Dockerfile
69+
FROM fluent/fluentd:v1.17-debian-1
70+
71+
# Use root account to use apt
72+
USER root
73+
74+
# below RUN includes plugin as examples elasticsearch is not required
75+
# you may customize including plugins as you wish
76+
RUN buildDeps="sudo make gcc g++ libc-dev" \
77+
&& apt-get update \
78+
&& apt-get install -y --no-install-recommends $buildDeps \
79+
&& sudo gem install fluent-plugin-elasticsearch \
80+
&& sudo gem sources --clear-all \
81+
&& SUDO_FORCE_REMOVE=yes \
82+
apt-get purge -y --auto-remove \
83+
-o APT::AutoRemove::RecommendsImportant=false \
84+
$buildDeps \
85+
&& rm -rf /var/lib/apt/lists/* \
86+
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
87+
88+
COPY fluent.conf /fluentd/etc/
89+
COPY entrypoint.sh /bin/
90+
91+
USER fluent
92+
```
93+
94+
#### Note
95+
96+
These example run `apk add`/`apt-get install` to be able to install
97+
Fluentd plugins which require native extensions (they are removed immediately
98+
after plugin installation).
99+
If you're sure that plugins don't include native extensions, you can omit it
100+
to make image build faster.
101+
102+
### 4. Build image
103+
104+
Use `docker build` command to build the image.
105+
This example names the image as `custom-fluentd:latest`:
106+
107+
```bash
108+
docker build -t custom-fluentd:latest ./
109+
```
110+
111+
### 5. Test it
112+
113+
Once the image is built, it's ready to run.
114+
Following commands run Fluentd sharing `./log` directory with the host machine:
115+
116+
```bash
117+
mkdir -p log
118+
docker run -it --rm --name custom-docker-fluent-logger -v $(pwd)/log:/fluentd/log custom-fluentd:latest
119+
```
120+
121+
Open another terminal and type following command to inspect IP address.
122+
Fluentd is running on this IP address:
123+
124+
```bash
125+
docker inspect -f '{{.NetworkSettings.IPAddress}}' custom-docker-fluent-logger
126+
```
127+
128+
Let's try to use another docker container to send its logs to Fluentd.
129+
130+
```bash
131+
docker run --log-driver=fluentd --log-opt tag="docker.{{.ID}}" --log-opt fluentd-address=FLUENTD.ADD.RE.SS:24224 python:alpine echo Hello
132+
# and force flush buffered logs
133+
docker kill -s USR1 custom-docker-fluent-logger
134+
```
135+
(replace `FLUENTD.ADD.RE.SS` with actual IP address you inspected at
136+
the previous step)
137+
138+
You will see some logs sent to Fluentd.

0 commit comments

Comments
 (0)