Skip to content

fix(build): remove busybox from dockerfile - #19502

Merged
fcjack merged 4 commits into
mainfrom
fcjack/remove-busybox-from-docker
Oct 17, 2025
Merged

fix(build): remove busybox from dockerfile#19502
fcjack merged 4 commits into
mainfrom
fcjack/remove-busybox-from-docker

Conversation

@fcjack

@fcjack fcjack commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Busybox included on our distroless dockerfile has a list of CVEs that needs to be addressed.

Going to remove the busybox from our dockerfile and use the distroless:nonroot as base image to follow best security practices.

Which issue(s) this PR fixes:
Fix CVEs:

Running grype scanner we see no vulnerabilities on this image:

grype fcjack/loki:fcjack-remove-busybox-from-docker-1750bf9
 ✔ Loaded image                                                                                                                                        fcjack/loki:fcjack-remove-busybox-from-docker-1750bf9 
 ✔ Parsed image                                                                                                                      sha256:52cf41545517f7a7412bbd3fbbd0c37a77ca9bea43cae7d3d4445b36bb913bed 
 ✔ Cataloged contents                                                                                                                       695770f9714e7ecee0d246ab19f850b5bdc82abe86e20beaa2d86f3ec68edbd6 
   ├── ✔ Packages                        [351 packages]  
   ├── ✔ Executables                     [1 executables]  
   ├── ✔ File metadata                   [947 locations]  
   └── ✔ File digests                    [947 files]  
 ✔ Scanned for vulnerabilities     [0 vulnerability matches]  
   ├── by severity: 0 critical, 0 high, 0 medium, 0 low, 0 negligible
No vulnerabilities found

@fcjack fcjack self-assigned this Oct 15, 2025
@fcjack fcjack added the docker Pull requests that update Docker code label Oct 15, 2025
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Oct 15, 2025
@fcjack
fcjack marked this pull request as ready for review October 16, 2025 15:01
@fcjack
fcjack requested a review from a team as a code owner October 16, 2025 15:01
Comment thread cmd/loki/Dockerfile Outdated
cp /tmp/local-config.yaml /tmp/etc/loki/local-config.yaml && \
addgroup --gid 10001 loki && \
adduser --uid 10001 --gid 10001 --disabled-password --gecos "" loki && \
chown -R loki:loki /tmp/etc/loki /tmp/loki

@slim-bean slim-bean Oct 16, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something feels off to me here, previously our final stage was setting the ownership and permissions and it set the permissions on the /loki directory

However now we are setting permissions on an intermediate build stage, and also we are setting it on /tmp/loki not /loki

This feels like it might be incorrect to me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because in our final stage we will use the distroless without sh, so I can't change in there.

The process is set in the intermediate, change the permissions first and then we can copy with from there with the right permissions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on directories, I updated now to not be on /tmp

@slim-bean slim-bean left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fcjack
fcjack merged commit f2ba692 into main Oct 17, 2025
66 checks passed
@fcjack
fcjack deleted the fcjack/remove-busybox-from-docker branch October 17, 2025 07:52
@guillaumedsde

Copy link
Copy Markdown

Hello 👋

Slimming down the Docker image seems like a good thing, thanks for that. However, it seems like the Loki binary does not include any way to run a healthcheck. As such, the Docker image for Loki >= 3.6.0 lacks any tools for performing a healthcheck, there is no shell to look for listening ports in the /proc filesystem, or wget to request the healthcheck endpoint which prevents users of the image from defining a docker healthcheck for the container.

Busybox is a bit overkill for that, but would you be open to adding a loki health command which would request the /health endpoint, exiting with an error code if loki is unhealthy? This would enable setting a docker healthcheck on containers instantiated with the official Loki Docker image (without re-adding all of busybox).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Pull requests that update Docker code size/M

3 participants