# Custom filebeat docker image error

**URL:** <https://discuss.elastic.co/t/custom-filebeat-docker-image-error/343140>\
**Category:** Beats\
**Tags:** docker, filebeat\
**Created:** [September 15, 2023, 12:59pm UTC](https://discuss.elastic.co/t/custom-filebeat-docker-image-error/343140 "2023-09-15T12:59:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheuscirillo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheuscirillo/32/118538_2.png) [@matheuscirillo](https://discuss.elastic.co/u/matheuscirillo)\
**Post date:** [September 15, 2023, 12:59pm UTC](https://discuss.elastic.co/t/custom-filebeat-docker-image-error/343140/1 "2023-09-15T12:59:11Z")

</div>

The [custom image configuration section](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-docker.html#_custom_image_configuration) on the docs says that we can do the following to create a customized image:

```plaintext
FROM docker.elastic.co/beats/filebeat:8.10.0
COPY --chown=root:filebeat filebeat.yml /usr/share/filebeat/filebeat.yml

```

So I created the Dockerfile just like this, but when I start the container, I have the following error logged:

```auto
error loading config file: config file ("filebeat.yml") can only be writable by the owner but the permissions are "-rw-rw-r--" (to fix the permissions use: 'chmod go-w /usr/share/filebeat/filebeat.yml')

```

Maybe `RUN chmod go-w /usr/share/filebeat/filebeat.yml` should be added to the Dockerfile?  
Let's try:

```plaintext
FROM docker.elastic.co/beats/filebeat:8.10.0
COPY --chown=root:filebeat filebeat.yml /usr/share/filebeat/filebeat.yml
RUN chmod go-w /usr/share/filebeat/filebeat.yml

```

```auto
$ docker build --tag xyz $("pwd")/filebeat-custom-img
[+] Building 0.2s (7/7) FINISHED docker:default
 => [internal] load .dockerignore 0.0s
 => => transferring context: 2B 0.0s
 => [internal] load build definition from Dockerfile 0.0s
 => => transferring dockerfile: 204B 0.0s
 => [internal] load metadata for docker.elastic.co/beats/filebeat:8.10.0 0.0s
 => [internal] load build context 0.0s
 => => transferring context: 34B 0.0s
 => [1/3] FROM docker.elastic.co/beats/filebeat:8.10.0 0.0s
 => CACHED [2/3] COPY --chown=root:filebeat filebeat.yml /usr/share/filebeat/filebeat.yml 0.0s
 => ERROR [3/3] RUN chmod go-w /usr/share/filebeat/filebeat.yml 0.2s
------
 > [3/3] RUN chmod go-w /usr/share/filebeat/filebeat.yml:
0.226 chmod: changing permissions of '/usr/share/filebeat/filebeat.yml': Operation not permitted

```

**chmod: changing permissions of '/usr/share/filebeat/filebeat.yml': Operation not permitted**

What to do in this situation?

---

<div class="post-metadata">

**Author:** ![matheuscirillo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheuscirillo/32/118538_2.png) [@matheuscirillo](https://discuss.elastic.co/u/matheuscirillo)\
**Post date:** [September 15, 2023, 1:05pm UTC](https://discuss.elastic.co/t/custom-filebeat-docker-image-error/343140/2 "2023-09-15T13:05:45Z")

</div>

So I solved by changing my Dockerfile to:

```plaintext
FROM docker.elastic.co/beats/filebeat:8.10.0
COPY --chown=filebeat filebeat.yml /usr/share/filebeat/filebeat.yml
RUN chmod go-w /usr/share/filebeat/filebeat.yml

```

I don't know if this is the best way to do, but it worked.  
If this configuration poses any risk, please, let me know.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 13, 2023, 3:05pm UTC](https://discuss.elastic.co/t/custom-filebeat-docker-image-error/343140/3 "2023-10-13T15:05:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
