Skip to content

Install only docker-cli for 30% smaller kamal docker image#1541

Merged
djmb merged 1 commit intobasecamp:mainfrom
polarctos:install-docker-cli-only
Jun 12, 2025
Merged

Install only docker-cli for 30% smaller kamal docker image#1541
djmb merged 1 commit intobasecamp:mainfrom
polarctos:install-docker-cli-only

Conversation

@polarctos
Copy link
Contributor

As only the docker client is executed in the image and not the docker server/daemon, only the docker-cli package is needed to be installed.

The docs already include the mount of the docker daemon socket from the host:
-v /var/run/docker.sock:/var/run/docker.sock
https://kamal-deploy.org/docs/installation/dockerized/

This reduced the image size from 733 MB to 511 MB for a local build for me, thus ca. 30% less.
Which makes the initial pull faster both on developer machines and in CI pipelines.

The image size could probably be reduced even further with Docker multi-stage builds.

Have you thought about packaging a fully native executable of releases? e.g. with Tebako or TruffleRuby
I think for non-Ruby developers this could reduce the barrier of using Kamal, as the suggested docker approach surely also works, but might look a bit cumbersome. Such a native binary could then probably also more easily be packaged for package managers like brew.

As only the docker client is executed in the image and not the docker daemon, only the docker-cli package is needed
@polarctos polarctos changed the title Install only docker-cli for leaner image Install only docker-cli for 30% smaller kamal docker image May 14, 2025
@polarctos
Copy link
Contributor Author

I tested the changes already locally and the resulting image still works the same.

Could a maintainer approve the workflow to see if the CI still passes too?

@djmb
Copy link
Collaborator

djmb commented Jun 12, 2025

Thanks @polarctos!

@djmb djmb merged commit c8f232b into basecamp:main Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants