Skip to content

devops : reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) - #4038

Open
turicas wants to merge 5 commits into
ggml-org:masterfrom
turicas:enhancement/optmize-docker-image
Open

devops : reduce Vulkan Docker image to 39.4% of its original size (now 692 MB)#4038
turicas wants to merge 5 commits into
ggml-org:masterfrom
turicas:enhancement/optmize-docker-image

Conversation

@turicas

@turicas turicas commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

The current Vulkan Docker image is 1.75 GB. Making it smaller not only reduces download and storage requirements, but can also make the image faster to build and distribute. This PR applies 4 changes to main-vulkan.Dockerfile, reducing the final image size from 1.75 GB to 692 MB (39.4% of the original size). The build time also decreased from 2m41s to 2m16s (84.4% of the original).

These were the main contributors to the current image size:

  • Installing recommended APT packages
  • Installing development packages in the runtime/final stage
  • Copying the entire repository and build artifacts into the runtime/final stage (including the base.en model)

I also made a couple of improvements:

  • Use apt instead of apt-get
  • Remove bash -c as the entrypoint

I'm willing to apply the same changes to the other Dockerfiles in the repository if the maintainers approve this approach. I started with the Vulkan image because it's the one I use.

Result:

$ docker image ls whispercpp-test
REPOSITORY        TAG                                   IMAGE ID       CREATED          SIZE
whispercpp-test   04-remove-entrypoint                  70eb4215ee40   11 minutes ago   692MB
whispercpp-test   03-copy-only-needed-files             57eeec07fb51   19 minutes ago   692MB
whispercpp-test   02-remove-dev-packages-from-runtime   35cde18f6236   22 minutes ago   1.37GB
whispercpp-test   01-do-not-install-recommends          5677b0c472aa   28 minutes ago   1.6GB
whispercpp-test   00-original                           2b93628d52a7   31 minutes ago   1.75GB

Notes:

  1. Regarding libsdl2-dev (removed in the second commit): commit bea43e0 (not mine) introduced this package in the runtime image, but since it's not required for production use, I think it should instead be installed by users who need it in an image derived from this one.
  2. I've run all the docker run commands from the README using the final Dockerfile in this PR and everything worked as expected (the examples were also fixed/extended).

Also:
- Replace apt-get with apt
- Explicitly install ca-certificates
Won't copy compiled tests, source code and other build artifacts.
With this change, arguments passed to `docker run` are forwarded
directly to the selected command.

Having `bash -c` in the entrypoint will cause additional arguments to be
interpreted according to shell command-string semantics, which makes
commands such as model downloaders and CLI tools behave unexpectedly
unless `--entrypoint` is specified explicitly or the whole command is
quoted.

Removing it restores the conventional Docker behavior of: `docker run
IMAGE COMMAND ARG...` passing `ARG` to `COMMAND` (not to `bash`).
@turicas turicas changed the title Reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) devops : reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) Sep 6, 2026
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.

1 participant