Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

images: Minimize container #388

Merged
merged 2 commits into from
Feb 20, 2021
Merged

images: Minimize container #388

merged 2 commits into from
Feb 20, 2021

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Feb 18, 2021

Use a multi-stage build [1], pick some "small container targetted" basic
packages, and remove some larger packages that we really don't need in
the container. This shrinks the container from 313 to 137 MB.

[1] https://docs.docker.com/develop/develop-images/multistage-build/


This was mostly a learning opportunity for me, I just saw @asamalik 's and @fatherlinux 's excellent building smaller container images devconf.cz talk. But then why not, now I earned some twitter bragging rights. 😁

I tested this locally, but our CI will test it in full.

@martinpitt
Copy link
Member Author

Ugh, what is that now -- totally unrelated:

Error: error streaming container content for copy up into volume 8c71c95cfd6484af8af086d9467dc6d8bf3d60070b24b774a9f36c65c8543231: copier: get: globs [/rabbitmq] matched nothing (0 filtered out): no such file or directory

@martinpitt
Copy link
Member Author

OK, seems I first need to debug that weird podman regression...

@martinpitt
Copy link
Member Author

I reported the podman failure at containers/podman#9432 , found a workaround, and added it here.

@martinpitt
Copy link
Member Author

The podman failure is known upstream and just got fixed. The current failure is now entirely my fault: No such file or directory: 'tar'. Yay integration tests!

Current podman 3.0.0 in system mode has a regression with handling
anonymous volumes. See containers/podman#9432
for details.

Work around this by placing RabbitMQ's data into a tmpfs volume.
Use a multi-stage build [1], pick some "small container targetted" basic
packages, and remove some larger packages that we really don't need in
the container. This shrinks the container from 313 to 137 MB.

[1] https://docs.docker.com/develop/develop-images/multistage-build/
@martinpitt
Copy link
Member Author

Nice, works! Just pushing again to clean up the commit message for the podman workaround.

Copy link
Member

@marusak marusak left a comment

Choose a reason for hiding this comment

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

Cool stuff indeed!
I am not super convinced it actually is necessary for this image to try to slim it down for the cost of making the dockerfile much harder to read.
I am not against nor in favor.

@martinpitt
Copy link
Member Author

Right, this was mostly a fun little learning project for me. It's not really relevant for production in this case, I'm also happy to just close this.

@martinpitt
Copy link
Member Author

I'd like to gain some experience with this, and also land the podman regression workaround. So if it's all the same to you, I'll land this. If it causes any problems, I'll revert.

@martinpitt martinpitt merged commit 5ef74a6 into master Feb 20, 2021
@martinpitt martinpitt deleted the images-minimize branch February 20, 2021 07:25
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