---
title: "Tech Tip #8: Slim your container images"
description: "Is your container a gigabyte, for a hundred-line service?"
url: https://greencode.ai/tech-tips/8-slim-your-container-images/
---

# Tech Tip #8: Slim your container images

**Is your container a gigabyte, for a hundred-line service?**

[Watch the video](https://media.greencode.ai/shorts/slim-your-container-images-8374a886638d.mp4)

Video created by [explainapaper.com](https://explainapaper.com/?utm_source=greencode.ai&utm_medium=film&utm_campaign=made-by)

### The problem

Images built on full operating-system bases carry compilers, shells and package caches into production. Every deploy stores, pulls and starts all of it, on every node.

### The fix you can use today

- Use slim, alpine or distroless base images.
- Build with multi-stage Dockerfiles and copy only the runtime artefacts.
- Leave dev dependencies and build tools out of the final image.

GreenCode researchers found that big container images waste energy.

### Tools that help

- [GreenCode Constitution skill](https://greencode-constitution.org/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): open-source energy principles and a catalogue of 37 energy anti-patterns that an AI coding agent can follow to find and fix waste like this
- [Docker build best practices](https://docs.docker.com/build/building/best-practices/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (Docker): multi-stage builds, small base images and leaving build tools out of the final image

### How GreenCode helps

GreenCode helps tackle this by mapping your running services and tracing energy and CO2e to the services that cause it. It shows which services run hot and which barely run at all. [More on this](https://greencode.ai/feature/infrastructure-carbon-footprint-assessment/).

### Tags

#docker#ci-cd#cloud

### Sources

- [GreenCode Constitution (Kapenekakis et al., GreenAI workshop, ECML PKDD 2026): oversized container images in Tier 3](https://greencode.ai/publications/greencode-constitution-agent-principles-for-optimizing-code-and-llm-inference-en/)
- [GreenCode Constitution skill, energy anti-patterns: R6 large container images: alpine or distroless instead of ubuntu/debian, 10-100x smaller](https://greencode-constitution.org/skill.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)

[All GreenCode Tech Tips](https://greencode.ai/tech-tips/)

#### Key Facts

- Tip **#8**
- For **Ops and infrastructure**
- Category **Containers, Kubernetes and serverless**
- Format **short video**
![GreenCode](https://greencode.ai/wp-content/uploads/2024/12/greencode-logo-website-small-colours-2.webp)

Want this checked on your own system? Talk to the GreenCode team.

[Get in touch](https://greencode.ai/contact/)
